You are here

protected function SimplenewsTestBase::getMail in Simplenews 3.x

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

Returns the body content of mail that has been sent.

Parameters

int $offset: Zero-based ordinal number of a sent mail. Defaults to most recent mail.

Return value

string The body of the mail.

5 calls to SimplenewsTestBase::getMail()
SimplenewsSubscribeTest::testAdminCreate in tests/src/Functional/SimplenewsSubscribeTest.php
Tests admin creating a single subscriber.
SimplenewsSubscribeTest::testHashAuth in tests/src/Functional/SimplenewsSubscribeTest.php
Tests access for a registered user to manage subscriptions with a hash.
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.
SimplenewsTestBase::assertMailText in tests/src/Functional/SimplenewsTestBase.php
Checks if a string is found in the latest sent mail.

File

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

Class

SimplenewsTestBase
Base class for simplenews web tests.

Namespace

Drupal\Tests\simplenews\Functional

Code

protected function getMail($offset = NULL) {
  $mails = $this
    ->getMails();
  if (!isset($offset)) {
    $offset = count($mails) - 1;
  }
  $this
    ->assertTrue(isset($mails[$offset]), t('Valid mails offset %offset (%count mails sent).', [
    '%offset' => $offset,
    '%count' => count($mails),
  ]));
  return $mails[$offset]['body'];
}