mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Scaffold additional tests
This commit is contained in:
parent
3cc72021b6
commit
bacfdc5049
|
@ -4,6 +4,7 @@ namespace Tests\Feature\Api\Assets;
|
||||||
|
|
||||||
use App\Events\CheckoutableCheckedIn;
|
use App\Events\CheckoutableCheckedIn;
|
||||||
use App\Models\Asset;
|
use App\Models\Asset;
|
||||||
|
use App\Models\LicenseSeat;
|
||||||
use App\Models\Location;
|
use App\Models\Location;
|
||||||
use App\Models\Statuslabel;
|
use App\Models\Statuslabel;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
@ -98,17 +99,38 @@ class AssetCheckinTest extends TestCase
|
||||||
|
|
||||||
public function testDefaultLocationCanBeUpdatedUponCheckin()
|
public function testDefaultLocationCanBeUpdatedUponCheckin()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$this->markTestIncomplete('Not currently in controller');
|
||||||
|
|
||||||
|
$location = Location::factory()->create();
|
||||||
|
$asset = Asset::factory()->assignedToUser()->create();
|
||||||
|
|
||||||
|
$this->actingAsForApi(User::factory()->checkinAssets()->create())
|
||||||
|
->postJson(route('api.asset.checkin', $asset), [
|
||||||
|
'location_id' => $location->id,
|
||||||
|
'update_default_location' => 0
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertTrue($asset->refresh()->defaultLoc()->is($location));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssetsLicenseSeatsAreClearedUponCheckin()
|
public function testAssetsLicenseSeatsAreClearedUponCheckin()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$this->markTestIncomplete('Not currently in controller');
|
||||||
|
|
||||||
|
$asset = Asset::factory()->assignedToUser()->create();
|
||||||
|
LicenseSeat::factory()->assignedToUser()->for($asset)->create();
|
||||||
|
|
||||||
|
$this->assertNotNull($asset->licenseseats->first()->assigned_to);
|
||||||
|
|
||||||
|
$this->actingAsForApi(User::factory()->checkinAssets()->create())
|
||||||
|
->postJson(route('api.asset.checkin', $asset));
|
||||||
|
|
||||||
|
$this->assertNull($asset->refresh()->licenseseats->first()->assigned_to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLegacyLocationValuesSetToZeroAreUpdated()
|
public function testLegacyLocationValuesSetToZeroAreUpdated()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$this->markTestIncomplete('Not currently in controller');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPendingCheckoutAcceptancesAreClearedUponCheckin()
|
public function testPendingCheckoutAcceptancesAreClearedUponCheckin()
|
||||||
|
@ -118,6 +140,20 @@ class AssetCheckinTest extends TestCase
|
||||||
|
|
||||||
public function testCheckinTimeAndActionLogNoteCanBeSet()
|
public function testCheckinTimeAndActionLogNoteCanBeSet()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$this->markTestIncomplete(
|
||||||
|
'checkin_at currently takes a date and applies a time which is not inline with what the web controller does.'
|
||||||
|
);
|
||||||
|
|
||||||
|
Event::fake();
|
||||||
|
|
||||||
|
$this->actingAsForApi(User::factory()->checkinAssets()->create())
|
||||||
|
->postJson(route('api.asset.checkin', Asset::factory()->assignedToUser()->create()), [
|
||||||
|
'checkin_at' => '2023-01-02 12:34:56',
|
||||||
|
'note' => 'hi there',
|
||||||
|
]);
|
||||||
|
|
||||||
|
Event::assertDispatched(function (CheckoutableCheckedIn $event) {
|
||||||
|
return $event->action_date === '2023-01-02 12:34:56' && $event->note === 'hi there';
|
||||||
|
}, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,12 +159,12 @@ class AssetCheckinTest extends TestCase
|
||||||
'hardware.checkin.store',
|
'hardware.checkin.store',
|
||||||
['assetId' => Asset::factory()->assignedToUser()->create()->id]
|
['assetId' => Asset::factory()->assignedToUser()->create()->id]
|
||||||
), [
|
), [
|
||||||
'checkin_at' => '2023-01-02 12:45:56',
|
'checkin_at' => '2023-01-02 12:34:56',
|
||||||
'note' => 'hello'
|
'note' => 'hello'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Event::assertDispatched(function (CheckoutableCheckedIn $event) {
|
Event::assertDispatched(function (CheckoutableCheckedIn $event) {
|
||||||
return $event->action_date === '2023-01-02 12:45:56' && $event->note === 'hello';
|
return $event->action_date === '2023-01-02 12:34:56' && $event->note === 'hello';
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue