Reputation: 11579
I am testing emails with sfTestMailer (delivery stratagy is none) How can I extract some text from sent email body?
Upvotes: 1
Views: 158
Reputation: 1983
I think you would have to extend the sfTesterMailer to get the message (which is there, but is protected). Right in your functional test maybe you can do this:
class myTesterMailer extends sfTesterMailer {
public function getMessage() {
return $this->message;
}
}
class myTestFunc extends sfTestFunctional {
public function getMessage() {
$message = $this->with('mailer')->getMessage();
return $message;
}
}
$browser = new myTestFunc(new sfBrowser(), null, array('mailer' => 'myTesterMailer'));
$message = $browser->getMessage();
... do tests on $message->getBody() ...
Upvotes: 2
Reputation: 4199
If you have properly configured your factories, this should work:
$browser->
//the rest of your test here
with('mailer')->begin()->
checkHeader('Subject', '/Hello world/')->
checkBody('/Hello stack overflow/')->
end();
More info is available in the documentation.
Upvotes: 1