You are here

protected function SimplenewsTestBase::assertMailText in Simplenews 8.2

Same name and namespace in other branches
  1. 3.x tests/src/Functional/SimplenewsTestBase.php \Drupal\Tests\simplenews\Functional\SimplenewsTestBase::assertMailText()

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.

2 calls to SimplenewsTestBase::assertMailText()
SimplenewsSubscribeTest::testSubscribeAnonymous in tests/src/Functional/SimplenewsSubscribeTest.php
TestSubscribeAnonymous.
SimplenewsSubscribeTest::testSubscribeMultiple in tests/src/Functional/SimplenewsSubscribeTest.php
Subscribe to multiple newsletters at the same time.

File

tests/src/Functional/SimplenewsTestBase.php, line 290

Class

SimplenewsTestBase
Base class for simplenews web tests.

Namespace

Drupal\Tests\simplenews\Functional

Code

protected function assertMailText($needle, $offset, $exist = TRUE) {
  $body = preg_replace('/\\s+/', ' ', $this
    ->getMail($offset));
  $this
    ->verbose($body);
  $pos = strpos($body, (string) $needle);
  $this
    ->assertEquals($pos !== FALSE, $exist, "{$needle} found in mail");
}