diff --git a/app/Listeners/LoginListener.php b/app/Listeners/LoginListener.php new file mode 100644 index 0000000..31f0146 --- /dev/null +++ b/app/Listeners/LoginListener.php @@ -0,0 +1,31 @@ +> */ protected $listen = [ + Login::class => [ + LoginListener::class, + ], + Logout::class => [ + LogoutListener::class, + ], Registered::class => [ SendEmailVerificationNotification::class, ], diff --git a/tests/Feature/EventTest.php b/tests/Feature/EventTest.php index 1cd59ff..8fb332c 100644 --- a/tests/Feature/EventTest.php +++ b/tests/Feature/EventTest.php @@ -5,11 +5,15 @@ use App\Events\OrderCreatedEvent; use App\Events\OrderDeletedEvent; use App\Events\OrderUpdatedEvent; +use App\Listeners\LoginListener; +use App\Listeners\LogoutListener; use App\Listeners\OrderCreationListener; use App\Listeners\OrderDeletionListener; use App\Listeners\OrderUpdateListener; use App\Models\Order; use App\Models\User; +use Illuminate\Auth\Events\Login; +use Illuminate\Auth\Events\Logout; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Support\Facades\Event; @@ -88,4 +92,14 @@ public function triggering_an_event_after_deleting_orders() Event::assertDispatched(OrderDeletedEvent::class); } + + /** @test */ + public function listening_to_builtin_events() + { + Event::fake(); + + Event::assertListening(Login::class, LoginListener::class); + + Event::assertListening(Logout::class, LogoutListener::class); + } }