You are here

protected function SimplenewsSubscribeTest::extractValidationLink in Simplenews 3.x

Extract a validation link from a mail body.

1 call to SimplenewsSubscribeTest::extractValidationLink()
SimplenewsSubscribeTest::testHashAuth in tests/src/Functional/SimplenewsSubscribeTest.php
Tests access for a registered user to manage subscriptions with a hash.

File

tests/src/Functional/SimplenewsSubscribeTest.php, line 179

Class

SimplenewsSubscribeTest
Un/subscription of anonymous and authenticated users.

Namespace

Drupal\Tests\simplenews\Functional

Code

protected function extractValidationLink($body) {
  $pattern = '@newsletter/subscriptions/.+/.+/.{20,}@';
  $found = preg_match($pattern, $body, $match);
  if (!$found) {
    $this
      ->fail(t('No validation URL found in "@body".', [
      '@body' => $body,
    ]));
    return FALSE;
  }
  $validate_url = $match[0];
  $this
    ->pass(t('Validation URL found: @url', [
    '@url' => $validate_url,
  ]));
  return $validate_url;
}