Closed RikSomers closed 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
}
@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
True, they both occur when passing an array of to- addresses.
PR submitted with a fix: https://github.com/laravel/framework/pull/16250
Description:
The MailFake / MailableFake test class is not capable of parsing multiple named recipients in the
to()
method, when using a collection of arrays in theMail::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:
TestMailable.php
)$emails = collect([ ['email' => 'example@example.com', 'name'=> 'example'] , ['email' => 'example2@example.com', 'name'=> 'example2'] ]);
Mail::fake()
methodMail::to($emails)->send(new TestMailable);
Mail::assertSentTo(['email' => 'example@example.com', 'name' => 'example']), TestMailable::class);
Array to string conversion
on the diff() line (line 88) inMailFake