Skip to main content

Testing Events with Event::fake()

Premium
2:14

The Full Lesson is Only for Premium Members

Want to access all of our courses? (30 h 01 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

C
Ch1Ch4 ✓ Link copied!

Hi Povilas,

I would suggest to add check for listener is attached to expected event in this lessons something like:

    /**
     * Be sure that listener attached to expected event
     * @test
     */
    public function it_has_listener_attached_to_an_event(): void
    {
        Event::fake();
        Event::assertListening(
            EventClass::class,
            ListenerClass::class
        );
    }

Best Regards

F
F_r ✓ Link copied!

this was remove from laravel 10 documentation. Someone know why please ?

F
F_r ✓ Link copied!

Hoooo it was moved to event page : https://laravel.com/docs/10.x/events#testing

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.