mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
Merge pull request #87 from jeffreyguo/pulls/email-plaintext
added step definition to check email contains a plain text
This commit is contained in:
commit
1062eb2910
@ -134,6 +134,28 @@ class EmailContext extends BehatContext
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Example: Given the email contains "Thank you for <strong>registering!<strong>".
|
||||
* Then the email should contain plain text "Thank you for registering!"
|
||||
* Assumes an email has been identified by a previous step,
|
||||
* e.g. through 'Given there should be an email to "test@test.com"'.
|
||||
*
|
||||
* @Given /^the email should contain plain text "([^"]*)"$/
|
||||
*/
|
||||
public function thereTheEmailContainsPlainText($content)
|
||||
{
|
||||
if(!$this->lastMatchedEmail) {
|
||||
throw new \LogicException('No matched email found from previous step');
|
||||
}
|
||||
|
||||
$email = $this->lastMatchedEmail;
|
||||
$emailContent = ($email->Content) ? ($email->Content) : ($email->PlainContent);
|
||||
$emailPlainText = strip_tags($emailContent);
|
||||
$emailPlainText = preg_replace("/\h+/", " ", $emailPlainText);
|
||||
|
||||
assertContains($content, $emailPlainText);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^I click on the "([^"]*)" link in the email (to|from) "([^"]*)"$/
|
||||
*/
|
||||
@ -223,6 +245,7 @@ class EmailContext extends BehatContext
|
||||
}
|
||||
// Convert html content to plain text
|
||||
$emailContent = strip_tags($emailContent);
|
||||
$emailContent = preg_replace("/\h+/", " ", $emailContent);
|
||||
$rows = $table->getRows();
|
||||
|
||||
// For "should not contain"
|
||||
|
Loading…
Reference in New Issue
Block a user