mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-23 12:44:12 -08:00
Updated tests
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
04e96b8f20
commit
43250ae881
|
@ -343,6 +343,7 @@ class AssetsController extends Controller
|
|||
$originalValues = $asset->getRawOriginal();
|
||||
$asset->assigned_to = null;
|
||||
$asset->assigned_type = null;
|
||||
$asset->accepted = null;
|
||||
|
||||
event(new CheckoutableCheckedIn($asset, $target, auth()->user(), 'Checkin on asset update', date('Y-m-d H:i:s'), $originalValues));
|
||||
}
|
||||
|
|
|
@ -73,34 +73,28 @@ class EditAssetTest extends TestCase
|
|||
Event::fake([CheckoutableCheckedIn::class]);
|
||||
|
||||
$user = User::factory()->create();
|
||||
$location = Location::factory()->create();
|
||||
$deployable_status = Statuslabel::factory()->rtd()->create();
|
||||
$achived_status = Statuslabel::factory()->archived()->create();
|
||||
|
||||
$asset = Asset::factory()->assignedToUser($user)->create(['status_id' => $deployable_status->id]);
|
||||
|
||||
$this->assertTrue($asset->assignedTo->is($user));
|
||||
|
||||
$currentTimestamp = now();
|
||||
|
||||
$this->actingAs(User::factory()->viewAssets()->editAssets()->create())
|
||||
->post(
|
||||
route('hardware.update', ['hardware' => $asset->id]),
|
||||
[
|
||||
->from(route('hardware.edit', $asset))
|
||||
->patch(route('hardware.update', $asset), [
|
||||
'status_id' => $achived_status->id,
|
||||
'model_id' => $asset->model_id,
|
||||
'asset_tag' => $asset->asset_tag,
|
||||
],
|
||||
);
|
||||
)
|
||||
->assertStatus(302);
|
||||
|
||||
$asset->refresh();
|
||||
\Log::error('AssignedTo: '.$asset->refresh()->assignedTo);
|
||||
\Log::error('Assigned_to: '.$asset->refresh()->assigned_to);
|
||||
\Log::error('Assigned_type: '.$asset->refresh()->assigned_type);
|
||||
$this->assertNull($asset->refresh()->assignedTo);
|
||||
$this->assertNull($asset->refresh()->assigned_type);
|
||||
$this->assertEquals($achived_status->id, $asset->refresh()->status_id);
|
||||
$this->assertNull($asset->assigned_type);
|
||||
$this->assertEquals($achived_status->id, $asset->status_id);
|
||||
|
||||
Event::assertDispatched(function (CheckoutableCheckedIn $event) use ($currentTimestamp) {
|
||||
// this could be better mocked but is ok for now.
|
||||
return Carbon::parse($event->action_date)->diffInSeconds($currentTimestamp) < 2;
|
||||
}, 1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue