Skip to content

Event assertListening expects both the params to be string #36939

Closed
@chaudigv

Description

@chaudigv
  • Laravel Version: 8.36.2
  • PHP Version: 7.4.12

Description:

I am creating a simple test to make sure verification email is sent upon successful registration. According to documentaion, I am suppose to use assertListening.
e.g.

Event::assertListening(
    OrderShipped::class,
    [SendShipmentNotification::class, 'handle']
);

Steps To Reproduce:

    public function test_send_verification_email_on_registered_event()
    {
        Event::fake();

        // throws error
        Event::assertListening(Registered::class, [SendEmailVerificationNotification::class, 'handle']);

        // Instead this works. Both the params must be strings
        Event::assertListening(Registered::class, SendEmailVerificationNotification::class);
    }

Am I missing something from void assertListening(string $expectedEvent, string $expectedListener)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions