protected function SimplenewsTestBase::assertMailText in Simplenews 8
Checks if a string is found in the latest sent mail.
Parameters
string $needle: The string to find.
int $offset: Specify to check the n:th last mail.
bool $exist: (optional) Whether the string is expected to be found or not.
Return value
bool Whether the string was found, or the inverted if $exist is FALSE.
2 calls to SimplenewsTestBase::assertMailText()
- SimplenewsSubscribeTest::testSubscribeAnonymous in src/
Tests/ SimplenewsSubscribeTest.php - testSubscribeAnonymous
- SimplenewsSubscribeTest::testSubscribeMultiple in src/
Tests/ SimplenewsSubscribeTest.php - Subscribe to multiple newsletters at the same time.
File
- src/
Tests/ SimplenewsTestBase.php, line 284 - Simplenews test functions.
Class
- SimplenewsTestBase
- Base class for simplenews web tests.
Namespace
Drupal\simplenews\TestsCode
protected function assertMailText($needle, $offset, $exist = TRUE) {
$body = preg_replace('/\\s+/', ' ', $this
->getMail($offset));
$this
->verbose($body);
$pos = strpos($body, (string) $needle);
return $this
->assertEqual($exist, $pos !== FALSE, "{$needle} found in mail");
}