mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 15:05:32 +00:00
Negation for email assertions
This commit is contained in:
parent
d003707894
commit
d09f2353e6
@ -64,26 +64,34 @@ class EmailContext extends BehatContext
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^there should be an email (to|from) "([^"]*)"$/
|
* @Given /^there should (not |)be an email (to|from) "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
public function thereIsAnEmailFromTo($direction, $email)
|
public function thereIsAnEmailFromTo($negate, $direction, $email)
|
||||||
{
|
{
|
||||||
$to = ($direction == 'to') ? $email : null;
|
$to = ($direction == 'to') ? $email : null;
|
||||||
$from = ($direction == 'from') ? $email : null;
|
$from = ($direction == 'from') ? $email : null;
|
||||||
$match = $this->mailer->findEmail($to, $from);
|
$match = $this->mailer->findEmail($to, $from);
|
||||||
assertNotNull($match);
|
if(trim($negate)) {
|
||||||
|
assertNull($match);
|
||||||
|
} else {
|
||||||
|
assertNotNull($match);
|
||||||
|
}
|
||||||
$this->lastMatchedEmail = $match;
|
$this->lastMatchedEmail = $match;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^there should be an email (to|from) "([^"]*)" titled "([^"]*)"$/
|
* @Given /^there should (not |)be an email (to|from) "([^"]*)" titled "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
public function thereIsAnEmailFromToTitled($direction, $email, $subject)
|
public function thereIsAnEmailFromToTitled($negate, $direction, $email, $subject)
|
||||||
{
|
{
|
||||||
$to = ($direction == 'to') ? $email : null;
|
$to = ($direction == 'to') ? $email : null;
|
||||||
$from = ($direction == 'from') ? $email : null;
|
$from = ($direction == 'from') ? $email : null;
|
||||||
$match = $this->mailer->findEmail($to, $from, $subject);
|
$match = $this->mailer->findEmail($to, $from, $subject);
|
||||||
assertNotNull($match);
|
if(trim($negate)) {
|
||||||
|
assertNull($match);
|
||||||
|
} else {
|
||||||
|
assertNotNull($match);
|
||||||
|
}
|
||||||
$this->lastMatchedEmail = $match;
|
$this->lastMatchedEmail = $match;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user