Fixed test for RMB
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
a0a0727b5c
commit
1b9d046f5f
1 changed files with 13 additions and 16 deletions
|
@ -18,16 +18,14 @@ class AssetCheckinTest extends TestCase
|
||||||
public function testCheckingInAssetRequiresCorrectPermission()
|
public function testCheckingInAssetRequiresCorrectPermission()
|
||||||
{
|
{
|
||||||
$this->actingAs(User::factory()->create())
|
$this->actingAs(User::factory()->create())
|
||||||
->post(route('hardware.checkin.store', [
|
->post(route('hardware.checkin.store', [Asset::factory()->assignedToUser()->create()]))
|
||||||
'assetId' => Asset::factory()->assignedToUser()->create()->id,
|
|
||||||
]))
|
|
||||||
->assertForbidden();
|
->assertForbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCannotCheckInAssetThatIsNotCheckedOut()
|
public function testCannotCheckInAssetThatIsNotCheckedOut()
|
||||||
{
|
{
|
||||||
$this->actingAs(User::factory()->checkinAssets()->create())
|
$this->actingAs(User::factory()->checkinAssets()->create())
|
||||||
->post(route('hardware.checkin.store', ['assetId' => Asset::factory()->create()->id]))
|
->post(route('hardware.checkin.store', [Asset::factory()->create()]))
|
||||||
->assertStatus(302)
|
->assertStatus(302)
|
||||||
->assertSessionHas('error')
|
->assertSessionHas('error')
|
||||||
->assertRedirect(route('hardware.index'));
|
->assertRedirect(route('hardware.index'));
|
||||||
|
@ -36,7 +34,7 @@ class AssetCheckinTest extends TestCase
|
||||||
public function testCannotStoreAssetCheckinThatIsNotCheckedOut()
|
public function testCannotStoreAssetCheckinThatIsNotCheckedOut()
|
||||||
{
|
{
|
||||||
$this->actingAs(User::factory()->checkinAssets()->create())
|
$this->actingAs(User::factory()->checkinAssets()->create())
|
||||||
->get(route('hardware.checkin.store', ['assetId' => Asset::factory()->create()->id]))
|
->get(route('hardware.checkin.store', [Asset::factory()->create()]))
|
||||||
->assertStatus(302)
|
->assertStatus(302)
|
||||||
->assertSessionHas('error')
|
->assertSessionHas('error')
|
||||||
->assertRedirect(route('hardware.index'));
|
->assertRedirect(route('hardware.index'));
|
||||||
|
@ -68,7 +66,7 @@ class AssetCheckinTest extends TestCase
|
||||||
|
|
||||||
$this->actingAs(User::factory()->checkinAssets()->create())
|
$this->actingAs(User::factory()->checkinAssets()->create())
|
||||||
->post(
|
->post(
|
||||||
route('hardware.checkin.store', ['assetId' => $asset->id]),
|
route('hardware.checkin.store', [$asset]),
|
||||||
[
|
[
|
||||||
'name' => 'Changed Name',
|
'name' => 'Changed Name',
|
||||||
'status_id' => $status->id,
|
'status_id' => $status->id,
|
||||||
|
@ -101,7 +99,7 @@ class AssetCheckinTest extends TestCase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->actingAs(User::factory()->checkinAssets()->create())
|
$this->actingAs(User::factory()->checkinAssets()->create())
|
||||||
->post(route('hardware.checkin.store', ['assetId' => $asset->id]));
|
->post(route('hardware.checkin.store', [$asset]));
|
||||||
|
|
||||||
$this->assertTrue($asset->refresh()->location()->is($rtdLocation));
|
$this->assertTrue($asset->refresh()->location()->is($rtdLocation));
|
||||||
}
|
}
|
||||||
|
@ -112,7 +110,7 @@ class AssetCheckinTest extends TestCase
|
||||||
$asset = Asset::factory()->assignedToUser()->create();
|
$asset = Asset::factory()->assignedToUser()->create();
|
||||||
|
|
||||||
$this->actingAs(User::factory()->checkinAssets()->create())
|
$this->actingAs(User::factory()->checkinAssets()->create())
|
||||||
->post(route('hardware.checkin.store', ['assetId' => $asset->id]), [
|
->post(route('hardware.checkin.store', [$asset]), [
|
||||||
'location_id' => $location->id,
|
'location_id' => $location->id,
|
||||||
'update_default_location' => 0
|
'update_default_location' => 0
|
||||||
]);
|
]);
|
||||||
|
@ -128,7 +126,7 @@ class AssetCheckinTest extends TestCase
|
||||||
$this->assertNotNull($asset->licenseseats->first()->assigned_to);
|
$this->assertNotNull($asset->licenseseats->first()->assigned_to);
|
||||||
|
|
||||||
$this->actingAs(User::factory()->checkinAssets()->create())
|
$this->actingAs(User::factory()->checkinAssets()->create())
|
||||||
->post(route('hardware.checkin.store', ['assetId' => $asset->id]));
|
->post(route('hardware.checkin.store', [$asset]));
|
||||||
|
|
||||||
$this->assertNull($asset->refresh()->licenseseats->first()->assigned_to);
|
$this->assertNull($asset->refresh()->licenseseats->first()->assigned_to);
|
||||||
}
|
}
|
||||||
|
@ -141,7 +139,7 @@ class AssetCheckinTest extends TestCase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->actingAs(User::factory()->checkinAssets()->create())
|
$this->actingAs(User::factory()->checkinAssets()->create())
|
||||||
->post(route('hardware.checkin.store', ['assetId' => $asset->id]));
|
->post(route('hardware.checkin.store', [$asset]));
|
||||||
|
|
||||||
$this->assertNull($asset->refresh()->rtd_location_id);
|
$this->assertNull($asset->refresh()->rtd_location_id);
|
||||||
$this->assertEquals($asset->location_id, $asset->rtd_location_id);
|
$this->assertEquals($asset->location_id, $asset->rtd_location_id);
|
||||||
|
@ -154,7 +152,7 @@ class AssetCheckinTest extends TestCase
|
||||||
$acceptance = CheckoutAcceptance::factory()->for($asset, 'checkoutable')->pending()->create();
|
$acceptance = CheckoutAcceptance::factory()->for($asset, 'checkoutable')->pending()->create();
|
||||||
|
|
||||||
$this->actingAs(User::factory()->checkinAssets()->create())
|
$this->actingAs(User::factory()->checkinAssets()->create())
|
||||||
->post(route('hardware.checkin.store', ['assetId' => $asset->id]));
|
->post(route('hardware.checkin.store', [$asset]));
|
||||||
|
|
||||||
$this->assertFalse($acceptance->exists(), 'Acceptance was not deleted');
|
$this->assertFalse($acceptance->exists(), 'Acceptance was not deleted');
|
||||||
}
|
}
|
||||||
|
@ -165,8 +163,7 @@ class AssetCheckinTest extends TestCase
|
||||||
|
|
||||||
$this->actingAs(User::factory()->checkinAssets()->create())
|
$this->actingAs(User::factory()->checkinAssets()->create())
|
||||||
->post(route(
|
->post(route(
|
||||||
'hardware.checkin.store',
|
'hardware.checkin.store', [Asset::factory()->assignedToUser()->create()]
|
||||||
['assetId' => Asset::factory()->assignedToUser()->create()->id]
|
|
||||||
), [
|
), [
|
||||||
'checkin_at' => '2023-01-02',
|
'checkin_at' => '2023-01-02',
|
||||||
'note' => 'hello'
|
'note' => 'hello'
|
||||||
|
@ -185,10 +182,10 @@ class AssetCheckinTest extends TestCase
|
||||||
$asset->forceSave();
|
$asset->forceSave();
|
||||||
|
|
||||||
$this->actingAs(User::factory()->admin()->create())
|
$this->actingAs(User::factory()->admin()->create())
|
||||||
->get(route('hardware.checkin.create', ['assetId' => $asset->id]))
|
->get(route('hardware.checkin.create', [$asset]))
|
||||||
->assertStatus(302)
|
->assertStatus(302)
|
||||||
->assertSessionHas('error')
|
->assertSessionHas('error')
|
||||||
->assertRedirect(route('hardware.show', $asset->id));
|
->assertRedirect(route('hardware.show', $asset));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssetCheckinPagePostIsRedirectedIfModelIsInvalid()
|
public function testAssetCheckinPagePostIsRedirectedIfModelIsInvalid()
|
||||||
|
@ -198,7 +195,7 @@ class AssetCheckinTest extends TestCase
|
||||||
$asset->forceSave();
|
$asset->forceSave();
|
||||||
|
|
||||||
$this->actingAs(User::factory()->admin()->create())
|
$this->actingAs(User::factory()->admin()->create())
|
||||||
->post(route('hardware.checkin.store', ['assetId' => $asset->id]))
|
->post(route('hardware.checkin.store', $asset))
|
||||||
->assertStatus(302)
|
->assertStatus(302)
|
||||||
->assertSessionHas('error')
|
->assertSessionHas('error')
|
||||||
->assertRedirect(route('hardware.show', $asset));
|
->assertRedirect(route('hardware.show', $asset));
|
||||||
|
|
Loading…
Add table
Reference in a new issue