|
@@ -23,7 +23,7 @@ public function testMailerSendSendsMessageWithProperViewContent() |
|
|
$message->shouldReceive('setFrom')->never(); |
|
|
$mailer->setSwiftMailer(m::mock('StdClass')); |
|
|
$message->shouldReceive('getSwiftMessage')->once()->andReturn($message); |
|
|
$mailer->getSwiftMailer()->shouldReceive('send')->once()->with($message); |
|
|
$mailer->getSwiftMailer()->shouldReceive('send')->once()->with($message, array()); |
|
|
$mailer->send('foo', array('data'), function($m) { $_SERVER['__mailer.test'] = $m; }); |
|
|
unset($_SERVER['__mailer.test']); |
|
|
} |
|
@@ -44,7 +44,7 @@ public function testMailerSendSendsMessageWithProperPlainViewContent() |
|
|
$message->shouldReceive('setFrom')->never(); |
|
|
$mailer->setSwiftMailer(m::mock('StdClass')); |
|
|
$message->shouldReceive('getSwiftMessage')->once()->andReturn($message); |
|
|
$mailer->getSwiftMailer()->shouldReceive('send')->once()->with($message); |
|
|
$mailer->getSwiftMailer()->shouldReceive('send')->once()->with($message, array()); |
|
|
$mailer->send(array('foo', 'bar'), array('data'), function($m) { $_SERVER['__mailer.test'] = $m; }); |
|
|
unset($_SERVER['__mailer.test']); |
|
|
} |
|
@@ -65,7 +65,7 @@ public function testMailerSendSendsMessageWithProperPlainViewContentWhenExplicit |
|
|
$message->shouldReceive('setFrom')->never(); |
|
|
$mailer->setSwiftMailer(m::mock('StdClass')); |
|
|
$message->shouldReceive('getSwiftMessage')->once()->andReturn($message); |
|
|
$mailer->getSwiftMailer()->shouldReceive('send')->once()->with($message); |
|
|
$mailer->getSwiftMailer()->shouldReceive('send')->once()->with($message, array()); |
|
|
$mailer->send(array('html' => 'foo', 'text' => 'bar'), array('data'), function($m) { $_SERVER['__mailer.test'] = $m; }); |
|
|
unset($_SERVER['__mailer.test']); |
|
|
} |
|
@@ -170,7 +170,7 @@ public function testMailerCanResolveMailerClasses() |
|
|
$message->shouldReceive('setFrom')->never(); |
|
|
$mailer->setSwiftMailer(m::mock('StdClass')); |
|
|
$message->shouldReceive('getSwiftMessage')->once()->andReturn($message); |
|
|
$mailer->getSwiftMailer()->shouldReceive('send')->once()->with($message); |
|
|
$mailer->getSwiftMailer()->shouldReceive('send')->once()->with($message, array()); |
|
|
$mailer->send('foo', array('data'), 'FooMailer'); |
|
|
} |
|
|
|
|
@@ -185,14 +185,30 @@ public function testGlobalFromIsRespectedOnAllMessages() |
|
|
$mailer->setSwiftMailer(m::mock('StdClass')); |
|
|
$mailer->alwaysFrom('taylorotwell@gmail.com', 'Taylor Otwell'); |
|
|
$me = $this; |
|
|
$mailer->getSwiftMailer()->shouldReceive('send')->once()->with(m::type('Swift_Message'))->andReturnUsing(function($message) use ($me) |
|
|
$mailer->getSwiftMailer()->shouldReceive('send')->once()->with(m::type('Swift_Message'), array())->andReturnUsing(function($message) use ($me) |
|
|
{ |
|
|
$me->assertEquals(array('taylorotwell@gmail.com' => 'Taylor Otwell'), $message->getFrom()); |
|
|
}); |
|
|
$mailer->send('foo', array('data'), function($m) {}); |
|
|
} |
|
|
|
|
|
|
|
|
public function testFailedRecipientsAreAppendedAndCanBeRetrieved() |
|
|
{ |
|
|
unset($_SERVER['__mailer.test']); |
|
|
$mailer = $this->getMailer(); |
|
|
$view = m::mock('StdClass'); |
|
|
$mailer->getViewEnvironment()->shouldReceive('make')->once()->andReturn($view); |
|
|
$view->shouldReceive('render')->once()->andReturn('rendered.view'); |
|
|
$swift = new FailingSwiftMailerStub; |
|
|
$mailer->setSwiftMailer($swift); |
|
|
|
|
|
$mailer->send('foo', array('data'), function($m) {}); |
|
|
|
|
|
$this->assertEquals(array('taylorotwell@gmail.com'), $mailer->getFailedRecipients()); |
|
|
} |
|
|
|
|
|
|
|
|
protected function getMailer() |
|
|
{ |
|
|
return new Illuminate\Mail\Mailer(m::mock('Illuminate\View\Environment'), m::mock('Swift_Mailer')); |
|
@@ -204,4 +220,12 @@ protected function getMocks() |
|
|
return array(m::mock('Illuminate\View\Environment'), m::mock('Swift_Mailer')); |
|
|
} |
|
|
|
|
|
}
|
|
|
} |
|
|
|
|
|
class FailingSwiftMailerStub |
|
|
{ |
|
|
public function send($message, &$failed) |
|
|
{ |
|
|
$failed[] = 'taylorotwell@gmail.com'; |
|
|
} |
|
|
} |