You are here

protected function SimplenewsTestBase::assertMailText in Simplenews 3.x

Same name and namespace in other branches
  1. 8.2 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: Zero-based ordinal number of a sent mail. Defaults to most recent mail.

bool $exist: (optional) Whether the string is expected to be found or not.

1 call to SimplenewsTestBase::assertMailText()
SimplenewsSubscribeTest::testSubscribeMultiple in tests/src/Functional/SimplenewsSubscribeTest.php
Subscribe to multiple newsletters at the same time.

File

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

Class

SimplenewsTestBase
Base class for simplenews web tests.

Namespace

Drupal\Tests\simplenews\Functional

Code

protected function assertMailText($needle, $offset = NULL, $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");
}