mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Improve event assertions
This commit is contained in:
parent
1fe22e4b7b
commit
f16c79bb9a
|
@ -852,12 +852,9 @@ class AssetsController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$checkout_at = request('checkout_at', date('Y-m-d H:i:s'));
|
$checkout_at = request('checkout_at', date('Y-m-d H:i:s'));
|
||||||
// @todo: test this
|
|
||||||
$expected_checkin = request('expected_checkin', null);
|
$expected_checkin = request('expected_checkin', null);
|
||||||
// @todo: test this
|
|
||||||
$note = request('note', null);
|
$note = request('note', null);
|
||||||
// Using `->has` preserves the asset name if the name parameter was not included in request.
|
// Using `->has` preserves the asset name if the name parameter was not included in request.
|
||||||
// @todo: test this
|
|
||||||
$asset_name = request()->has('name') ? request('name') : $asset->name;
|
$asset_name = request()->has('name') ? request('name') : $asset->name;
|
||||||
|
|
||||||
// Set the location ID to the RTD location id if there is one
|
// Set the location ID to the RTD location id if there is one
|
||||||
|
|
|
@ -166,7 +166,8 @@ class AssetCheckoutTest extends TestCase
|
||||||
'expected_checkin' => '2024-04-08',
|
'expected_checkin' => '2024-04-08',
|
||||||
'name' => 'Changed Name',
|
'name' => 'Changed Name',
|
||||||
'note' => 'Here is a cool note!',
|
'note' => 'Here is a cool note!',
|
||||||
]);
|
])
|
||||||
|
->assertOk();
|
||||||
|
|
||||||
$asset->refresh();
|
$asset->refresh();
|
||||||
$this->assertTrue($asset->assignedTo()->is($target));
|
$this->assertTrue($asset->assignedTo()->is($target));
|
||||||
|
@ -181,10 +182,12 @@ class AssetCheckoutTest extends TestCase
|
||||||
|
|
||||||
Event::assertDispatched(CheckoutableCheckedOut::class, 1);
|
Event::assertDispatched(CheckoutableCheckedOut::class, 1);
|
||||||
Event::assertDispatched(function (CheckoutableCheckedOut $event) use ($admin, $asset, $target) {
|
Event::assertDispatched(function (CheckoutableCheckedOut $event) use ($admin, $asset, $target) {
|
||||||
return $event->checkoutable->is($asset)
|
$this->assertTrue($event->checkoutable->is($asset));
|
||||||
&& $event->checkedOutTo->is($target)
|
$this->assertTrue($event->checkedOutTo->is($target));
|
||||||
&& $event->checkedOutBy->is($admin)
|
$this->assertTrue($event->checkedOutBy->is($admin));
|
||||||
&& $event->note === 'Here is a cool note!';
|
$this->assertEquals('Here is a cool note!', $event->note);
|
||||||
|
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue