Closed ibrunotome closed 5 months ago
Seems like the same as https://github.com/laravel/framework/issues/51610. Are you using the EventServiceProvider directly in v11? See https://laravel.com/docs/11.x/releases#service-providers
No, my bootstrap/app.php has only AppServiceProvider, but I was registering the event/listener in AppServiceProvider with:
Event::listen(Registered::class, SendEmailVerificationNotification::class);
Event::listen(Registered::class, SendWelcomeNotification::class);
Event::listen(WebhookReceived::class, StripeEventListener::class);
removing it from AppServiceProvider and running the test agains, It passes like it was in v11.8 and previous versions.
Hey there, thanks for reporting this issue.
We'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue as one separate commit on the main/master branch and share the repository here?
Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up.
laravel new bug-report --github="--public"
Do not amend and create a separate commit with your custom changes. After you've posted the repository, we'll try to reproduce the issue.
Thanks!
removing it from AppServiceProvider and running the test agains, It passes like it was in v11.8 and previous versions.
Yes that is the expected behaviour now.
Laravel Version
11.10.0
PHP Version
8.3.4
Database Driver & Version
sqlite
Description
Since 11.9.0, the event Registered dispatched on RegisteredUserController is being listened twice, so this test:
started to fail:
Tests\Feature\Auth\RegistrationTest > new users can register Expected [App\Notifications\WelcomeNotification] to be sent 1 times, but was sent 2 times. Failed asserting that 2 is identical to 1.
While writing this issue I noted that this only occurs if the argument $event in the listener has the explicit type, like
handle(Registered $event)
Steps To Reproduce
composer create-project laravel/laravel:^11.9 example-app
composer require laravel/breeze
php artisan breeze:install
php artisan make:notification WelcomeNotification
php artisan make:listener SendWelcomeNotification
So it's like the type before $event is dispatching the event again? I mean, this is not the behavior prior v11.9.0, the test pass in v11.8.0 and below.