You are here

function SimplenewsSubscribeTest::extractConfirmationLink in Simplenews 8

Extract a confirmation link from a mail body.

2 calls to SimplenewsSubscribeTest::extractConfirmationLink()
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/SimplenewsSubscribeTest.php, line 300
Simplenews subscribe test functions.

Class

SimplenewsSubscribeTest
(un)subscription of anonymous and authenticated users.

Namespace

Drupal\simplenews\Tests

Code

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', array(
    '@url' => $confirm_url,
  )));
  return $confirm_url;
}