mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 07:34:06 -08:00
Consolidate test cases
This commit is contained in:
parent
bacfdc5049
commit
905df5ec25
|
@ -42,6 +42,7 @@ class AssetCheckinTest extends TestCase
|
||||||
Event::fake([CheckoutableCheckedIn::class]);
|
Event::fake([CheckoutableCheckedIn::class]);
|
||||||
|
|
||||||
$user = User::factory()->create();
|
$user = User::factory()->create();
|
||||||
|
$location = Location::factory()->create();
|
||||||
$status = Statuslabel::factory()->create();
|
$status = Statuslabel::factory()->create();
|
||||||
$asset = Asset::factory()->assignedToUser($user)->create([
|
$asset = Asset::factory()->assignedToUser($user)->create([
|
||||||
'expected_checkin' => now()->addDay(),
|
'expected_checkin' => now()->addDay(),
|
||||||
|
@ -55,6 +56,7 @@ class AssetCheckinTest extends TestCase
|
||||||
->postJson(route('api.asset.checkin', $asset), [
|
->postJson(route('api.asset.checkin', $asset), [
|
||||||
'name' => 'Changed Name',
|
'name' => 'Changed Name',
|
||||||
'status_id' => $status->id,
|
'status_id' => $status->id,
|
||||||
|
'location_id' => $location->id,
|
||||||
])
|
])
|
||||||
->assertOk();
|
->assertOk();
|
||||||
|
|
||||||
|
@ -68,6 +70,7 @@ class AssetCheckinTest extends TestCase
|
||||||
$this->assertNull($asset->accepted);
|
$this->assertNull($asset->accepted);
|
||||||
$this->assertEquals('Changed Name', $asset->name);
|
$this->assertEquals('Changed Name', $asset->name);
|
||||||
$this->assertEquals($status->id, $asset->status_id);
|
$this->assertEquals($status->id, $asset->status_id);
|
||||||
|
$this->assertTrue($asset->location()->is($location));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLocationIsSetToRTDLocationByDefaultUponCheckin()
|
public function testLocationIsSetToRTDLocationByDefaultUponCheckin()
|
||||||
|
@ -84,19 +87,6 @@ class AssetCheckinTest extends TestCase
|
||||||
$this->assertTrue($asset->refresh()->location()->is($rtdLocation));
|
$this->assertTrue($asset->refresh()->location()->is($rtdLocation));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLocationCanBeSetUponCheckin()
|
|
||||||
{
|
|
||||||
$location = Location::factory()->create();
|
|
||||||
$asset = Asset::factory()->assignedToUser()->create();
|
|
||||||
|
|
||||||
$this->actingAsForApi(User::factory()->checkinAssets()->create())
|
|
||||||
->postJson(route('api.asset.checkin', $asset->id), [
|
|
||||||
'location_id' => $location->id,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->assertTrue($asset->refresh()->location()->is($location));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDefaultLocationCanBeUpdatedUponCheckin()
|
public function testDefaultLocationCanBeUpdatedUponCheckin()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Not currently in controller');
|
$this->markTestIncomplete('Not currently in controller');
|
||||||
|
|
|
@ -39,6 +39,7 @@ class AssetCheckinTest extends TestCase
|
||||||
Event::fake([CheckoutableCheckedIn::class]);
|
Event::fake([CheckoutableCheckedIn::class]);
|
||||||
|
|
||||||
$user = User::factory()->create();
|
$user = User::factory()->create();
|
||||||
|
$location = Location::factory()->create();
|
||||||
$status = Statuslabel::first() ?? Statuslabel::factory()->create();
|
$status = Statuslabel::first() ?? Statuslabel::factory()->create();
|
||||||
$asset = Asset::factory()->assignedToUser($user)->create([
|
$asset = Asset::factory()->assignedToUser($user)->create([
|
||||||
'expected_checkin' => now()->addDay(),
|
'expected_checkin' => now()->addDay(),
|
||||||
|
@ -54,6 +55,7 @@ class AssetCheckinTest extends TestCase
|
||||||
[
|
[
|
||||||
'name' => 'Changed Name',
|
'name' => 'Changed Name',
|
||||||
'status_id' => $status->id,
|
'status_id' => $status->id,
|
||||||
|
'location_id' => $location->id,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
->assertRedirect(route('users.show', $user));
|
->assertRedirect(route('users.show', $user));
|
||||||
|
@ -68,6 +70,7 @@ class AssetCheckinTest extends TestCase
|
||||||
$this->assertNull($asset->accepted);
|
$this->assertNull($asset->accepted);
|
||||||
$this->assertEquals('Changed Name', $asset->name);
|
$this->assertEquals('Changed Name', $asset->name);
|
||||||
$this->assertEquals($status->id, $asset->status_id);
|
$this->assertEquals($status->id, $asset->status_id);
|
||||||
|
$this->assertTrue($asset->location()->is($location));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLocationIsSetToRTDLocationByDefaultUponCheckin()
|
public function testLocationIsSetToRTDLocationByDefaultUponCheckin()
|
||||||
|
@ -84,19 +87,6 @@ class AssetCheckinTest extends TestCase
|
||||||
$this->assertTrue($asset->refresh()->location()->is($rtdLocation));
|
$this->assertTrue($asset->refresh()->location()->is($rtdLocation));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLocationCanBeSetUponCheckin()
|
|
||||||
{
|
|
||||||
$location = Location::factory()->create();
|
|
||||||
$asset = Asset::factory()->assignedToUser()->create();
|
|
||||||
|
|
||||||
$this->actingAs(User::factory()->checkinAssets()->create())
|
|
||||||
->post(route('hardware.checkin.store', ['assetId' => $asset->id]), [
|
|
||||||
'location_id' => $location->id,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->assertTrue($asset->refresh()->location()->is($location));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDefaultLocationCanBeUpdatedUponCheckin()
|
public function testDefaultLocationCanBeUpdatedUponCheckin()
|
||||||
{
|
{
|
||||||
$location = Location::factory()->create();
|
$location = Location::factory()->create();
|
||||||
|
|
Loading…
Reference in a new issue