mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -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();
|
$originalValues = $asset->getRawOriginal();
|
||||||
$asset->assigned_to = null;
|
$asset->assigned_to = null;
|
||||||
$asset->assigned_type = 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));
|
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]);
|
Event::fake([CheckoutableCheckedIn::class]);
|
||||||
|
|
||||||
$user = User::factory()->create();
|
$user = User::factory()->create();
|
||||||
$location = Location::factory()->create();
|
|
||||||
$deployable_status = Statuslabel::factory()->rtd()->create();
|
$deployable_status = Statuslabel::factory()->rtd()->create();
|
||||||
$achived_status = Statuslabel::factory()->archived()->create();
|
$achived_status = Statuslabel::factory()->archived()->create();
|
||||||
|
|
||||||
$asset = Asset::factory()->assignedToUser($user)->create(['status_id' => $deployable_status->id]);
|
$asset = Asset::factory()->assignedToUser($user)->create(['status_id' => $deployable_status->id]);
|
||||||
|
|
||||||
$this->assertTrue($asset->assignedTo->is($user));
|
$this->assertTrue($asset->assignedTo->is($user));
|
||||||
|
|
||||||
$currentTimestamp = now();
|
$currentTimestamp = now();
|
||||||
|
|
||||||
$this->actingAs(User::factory()->viewAssets()->editAssets()->create())
|
$this->actingAs(User::factory()->viewAssets()->editAssets()->create())
|
||||||
->post(
|
->from(route('hardware.edit', $asset))
|
||||||
route('hardware.update', ['hardware' => $asset->id]),
|
->patch(route('hardware.update', $asset), [
|
||||||
[
|
|
||||||
'status_id' => $achived_status->id,
|
'status_id' => $achived_status->id,
|
||||||
|
'model_id' => $asset->model_id,
|
||||||
|
'asset_tag' => $asset->asset_tag,
|
||||||
],
|
],
|
||||||
);
|
)
|
||||||
|
->assertStatus(302);
|
||||||
|
|
||||||
$asset->refresh();
|
$asset->refresh();
|
||||||
\Log::error('AssignedTo: '.$asset->refresh()->assignedTo);
|
$this->assertNull($asset->assigned_type);
|
||||||
\Log::error('Assigned_to: '.$asset->refresh()->assigned_to);
|
$this->assertEquals($achived_status->id, $asset->status_id);
|
||||||
\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);
|
|
||||||
|
|
||||||
Event::assertDispatched(function (CheckoutableCheckedIn $event) use ($currentTimestamp) {
|
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;
|
return Carbon::parse($event->action_date)->diffInSeconds($currentTimestamp) < 2;
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue