You are here

protected function SimplenewsSubscribeTest::extractConfirmationLink in Simplenews 8.2

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

Extract a confirmation link from a mail body.

3 calls to SimplenewsSubscribeTest::extractConfirmationLink()
SimplenewsSubscribeTest::testAdminCreate in tests/src/Functional/SimplenewsSubscribeTest.php
Tests admin creating a single subscriber.
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/SimplenewsSubscribeTest.php, line 295

Class

SimplenewsSubscribeTest
Un/subscription of anonymous and authenticated users.

Namespace

Drupal\Tests\simplenews\Functional

Code

protected function extractConfirmationLink($body) {
  $pattern = '@newsletter/confirm/.+@';
  preg_match($pattern, $body, $match);
  $found = preg_match($pattern, $body, $match);
  if (!$found) {
    $this
      ->fail('Confirmation URL found.');
    return FALSE;
  }
  $confirm_url = $match[0];
  $this
    ->pass(t('Confirmation URL found: @url', [
    '@url' => $confirm_url,
  ]));
  return $confirm_url;
}