laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.51k stars 11.02k forks source link

MailFake / MailableFake not working with multiple named to-recipients #16094

Closed RikSomers closed 8 years ago

RikSomers commented 8 years ago

The MailFake / MailableFake test class is not capable of parsing multiple named recipients in the to() method, when using a collection of arrays in the Mail::to() method. The mailable will however be sent correctly with the same code when not using the MailFake and using the normal Mail class.

On the MailFake, it tries to do a array_diff-call on a multidimensional array, causing an error.

Steps To Reproduce:

andzandz commented 8 years ago

I was about to post an issue for this as well.

    public function testMailable()
    {
        Mail::fake();

        $settings = (app(SettingsBuilder::class))->toArray();
        $mailable = new CurrencyFeedDown24HoursMailable($settings, '18 hours', '2016-10-23 08:56');

        Mail::to(['foo@bar.com','bar@foo.com'])->send($mailable);

        Mail::assertSentTo(['foo@bar.com','bar@foo.com'], CurrencyFeedDown24HoursMailable::class); //passes
        Mail::assertSentTo(['bar@foo.com','foo@bar.com'], CurrencyFeedDown24HoursMailable::class); //passes
        Mail::assertSentTo(['foo@bar.com'], CurrencyFeedDown24HoursMailable::class); //fails
        Mail::assertSentTo('foo@bar.com', CurrencyFeedDown24HoursMailable::class);   //fails
    }
RikSomers commented 8 years ago

@andzandz Your problem is probably related (and can be fixed with the same changes) but is a tad different to mine right? You dont work with a multidimensional array.

Also, fixed a typo in my title

andzandz commented 8 years ago

True, they both occur when passing an array of to- addresses.

themsaid commented 8 years ago

PR submitted with a fix: https://github.com/laravel/framework/pull/16250