mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
Merge pull request #91 from jeffreyguo/pulls/email-from-to-titled
Find email by title then check the recipents
This commit is contained in:
commit
efd8f65c33
@ -709,6 +709,12 @@ It's based on the `vendor/bin/behat -di @cms` output.
|
|||||||
Then /^the email should (not |)contain the following data:$/
|
Then /^the email should (not |)contain the following data:$/
|
||||||
Example: Then the email should contain the following data:
|
Example: Then the email should contain the following data:
|
||||||
|
|
||||||
|
Then /^there should (not |)be an email titled "([^"]*)"$/
|
||||||
|
|
||||||
|
Then /^the email should (not |)be sent from "([^"]*)"$/
|
||||||
|
|
||||||
|
Then /^the email should (not |)be sent to "([^"]*)"$/
|
||||||
|
|
||||||
### Transformations
|
### Transformations
|
||||||
|
|
||||||
Behat [transformations](http://docs.behat.org/guides/2.definitions.html#step-argument-transformations)
|
Behat [transformations](http://docs.behat.org/guides/2.definitions.html#step-argument-transformations)
|
||||||
|
@ -236,4 +236,56 @@ class EmailContext extends BehatContext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Then /^there should (not |)be an email titled "([^"]*)"$/
|
||||||
|
*/
|
||||||
|
public function thereIsAnEmailTitled($negate, $subject)
|
||||||
|
{
|
||||||
|
$match = $this->mailer->findEmail(null, null, $subject);
|
||||||
|
if(trim($negate)) {
|
||||||
|
assertNull($match);
|
||||||
|
} else {
|
||||||
|
$msg = sprintf(
|
||||||
|
'Could not find email titled "%s".',
|
||||||
|
$subject
|
||||||
|
);
|
||||||
|
assertNotNull($match,$msg);
|
||||||
|
}
|
||||||
|
$this->lastMatchedEmail = $match;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Then /^the email should (not |)be sent from "([^"]*)"$/
|
||||||
|
*/
|
||||||
|
public function theEmailSentFrom($negate, $from)
|
||||||
|
{
|
||||||
|
if(!$this->lastMatchedEmail) {
|
||||||
|
throw new \LogicException('No matched email found from previous step');
|
||||||
|
}
|
||||||
|
|
||||||
|
$match = $this->lastMatchedEmail;
|
||||||
|
if(trim($negate)) {
|
||||||
|
assertNotContains($from, $match->From);
|
||||||
|
} else {
|
||||||
|
assertContains($from, $match->From);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Then /^the email should (not |)be sent to "([^"]*)"$/
|
||||||
|
*/
|
||||||
|
public function theEmailSentTo($negate, $to)
|
||||||
|
{
|
||||||
|
if(!$this->lastMatchedEmail) {
|
||||||
|
throw new \LogicException('No matched email found from previous step');
|
||||||
|
}
|
||||||
|
|
||||||
|
$match = $this->lastMatchedEmail;
|
||||||
|
if(trim($negate)) {
|
||||||
|
assertNotContains($to, $match->To);
|
||||||
|
} else {
|
||||||
|
assertContains($to, $match->To);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user