diff --git a/tests/Feature/Checkouts/AssetCheckoutTest.php b/tests/Feature/Checkouts/AssetCheckoutTest.php index b04a44cdb4..fb72b741b2 100644 --- a/tests/Feature/Checkouts/AssetCheckoutTest.php +++ b/tests/Feature/Checkouts/AssetCheckoutTest.php @@ -103,6 +103,7 @@ class AssetCheckoutTest extends TestCase $this->assertEquals('2024-03-18 00:00:00', $asset->last_checkout); $this->assertEquals('2024-03-28 00:00:00', (string)$asset->expected_checkin); + Event::assertDispatched(CheckoutableCheckedOut::class, 1); Event::assertDispatched(function (CheckoutableCheckedOut $event) use ($admin, $asset, $user) { return $event->checkoutable->is($asset) && $event->checkedOutTo->is($user) diff --git a/tests/Unit/Listeners/LogListenerTest.php b/tests/Unit/Listeners/LogListenerTest.php new file mode 100644 index 0000000000..ca20bc0a96 --- /dev/null +++ b/tests/Unit/Listeners/LogListenerTest.php @@ -0,0 +1,37 @@ +create(); + $checkedOutTo = User::factory()->create(); + $checkedOutBy = User::factory()->create(); + $this->actingAs($checkedOutBy); + + (new LogListener())->onCheckoutableCheckedOut(new CheckoutableCheckedOut( + $asset, + $checkedOutTo, + $checkedOutBy, + 'A simple note...', + )); + + $this->assertDatabaseHas('action_logs', [ + 'action_type' => 'checkout', + 'user_id' => $checkedOutBy->id, + 'target_id' => $checkedOutTo->id, + 'target_type' => User::class, + 'item_id' => $asset->id, + 'item_type' => Asset::class, + 'note' => 'A simple note...', + ]); + } +}