protected function SimplenewsSubscribeTest::extractConfirmationLink in Simplenews 3.x
Same name and namespace in other branches
- 8.2 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 164
Class
- SimplenewsSubscribeTest
- Un/subscription of anonymous and authenticated users.
Namespace
Drupal\Tests\simplenews\FunctionalCode
protected function extractConfirmationLink($body) {
$pattern = '@newsletter/confirm/.+/.+/.+/.{20,}@';
$found = preg_match($pattern, $body, $match);
if (!$found) {
$this
->fail(t('No confirmation URL found in "@body".', [
'@body' => $body,
]));
return FALSE;
}
$confirm_url = $match[0];
$this
->pass(t('Confirmation URL found: @url', [
'@url' => $confirm_url,
]));
return $confirm_url;
}