mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 14:27:33 -08:00
Added tests for due-or-overdue
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
fc61a4b88d
commit
494ec5cd9c
|
@ -65,6 +65,25 @@ class AssetIndexTest extends TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testAssetApiIndexReturnsDueOrOverdueForAudit()
|
||||||
|
{
|
||||||
|
Asset::factory()->count(3)->create(['next_audit_date' => Carbon::now()->format('Y-m-d')]);
|
||||||
|
Asset::factory()->count(2)->create(['next_audit_date' => Carbon::now()->subDays(1)->format('Y-m-d')]);
|
||||||
|
|
||||||
|
$this->assertTrue(Asset::count() === 5);
|
||||||
|
|
||||||
|
$this->actingAsForApi(User::factory()->superuser()->create())
|
||||||
|
->getJson(
|
||||||
|
route('api.assets.list-upcoming', ['action' => 'audits', 'upcoming_status' => 'due-or-overdue']))
|
||||||
|
->assertOk()
|
||||||
|
->assertJsonStructure([
|
||||||
|
'total',
|
||||||
|
'rows',
|
||||||
|
])
|
||||||
|
->assertJson(fn(AssertableJson $json) => $json->has('rows', 5)->etc());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function testAssetApiIndexReturnsDueForExpectedCheckin()
|
public function testAssetApiIndexReturnsDueForExpectedCheckin()
|
||||||
{
|
{
|
||||||
|
@ -100,6 +119,23 @@ class AssetIndexTest extends TestCase
|
||||||
->assertJson(fn(AssertableJson $json) => $json->has('rows', 3)->etc());
|
->assertJson(fn(AssertableJson $json) => $json->has('rows', 3)->etc());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testAssetApiIndexReturnsDueOrOverdueForExpectedCheckin()
|
||||||
|
{
|
||||||
|
Asset::factory()->count(3)->create(['assigned_to' => '1', 'expected_checkin' => Carbon::now()->subDays(1)->format('Y-m-d')]);
|
||||||
|
Asset::factory()->count(2)->create(['assigned_to' => '1', 'expected_checkin' => Carbon::now()->format('Y-m-d')]);
|
||||||
|
|
||||||
|
$this->assertTrue(Asset::count() === 5);
|
||||||
|
|
||||||
|
$this->actingAsForApi(User::factory()->superuser()->create())
|
||||||
|
->getJson(route('api.assets.list-upcoming', ['action' => 'checkins', 'upcoming_status' => 'due-or-overdue']))
|
||||||
|
->assertOk()
|
||||||
|
->assertJsonStructure([
|
||||||
|
'total',
|
||||||
|
'rows',
|
||||||
|
])
|
||||||
|
->assertJson(fn(AssertableJson $json) => $json->has('rows', 5)->etc());
|
||||||
|
}
|
||||||
|
|
||||||
public function testAssetApiIndexAdheresToCompanyScoping()
|
public function testAssetApiIndexAdheresToCompanyScoping()
|
||||||
{
|
{
|
||||||
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
||||||
|
|
Loading…
Reference in a new issue