Uses Helper's replaceLinkTags method to replace activation link in
subscription confirmation email
This commit is contained in:
@@ -104,16 +104,11 @@ class Subscriber extends Model {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// replace activation link
|
// replace activation link
|
||||||
$body = str_replace(
|
$body = Helpers::replaceLinkTags(
|
||||||
array(
|
$body,
|
||||||
'[activation_link]',
|
Subscription\Url::getConfirmationUrl($this),
|
||||||
'[/activation_link]'
|
array('target' => '_blank'),
|
||||||
),
|
'activation_link'
|
||||||
array(
|
|
||||||
'<a href="'.esc_attr(Subscription\Url::getConfirmationUrl($this)).'">',
|
|
||||||
'</a>'
|
|
||||||
),
|
|
||||||
$body
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// build email data
|
// build email data
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use AspectMock\Test as Mock;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Codeception\Util\Fixtures;
|
use Codeception\Util\Fixtures;
|
||||||
use MailPoet\Models\CustomField;
|
use MailPoet\Models\CustomField;
|
||||||
@@ -1047,6 +1048,48 @@ class SubscriberTest extends MailPoetTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testItSendsConfirmationEmail() {
|
||||||
|
Mock::double('MailPoet\Mailer\Mailer', [
|
||||||
|
'__construct' => null,
|
||||||
|
'send' => function($email) {
|
||||||
|
return $email;
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
Mock::double('MailPoet\Subscription\Url', [
|
||||||
|
'getConfirmationUrl' => 'http://example.com'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$segment = Segment::createOrUpdate(
|
||||||
|
array(
|
||||||
|
'name' => 'Test segment'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
SubscriberSegment::subscribeToSegments(
|
||||||
|
$this->subscriber,
|
||||||
|
array($segment->id)
|
||||||
|
);
|
||||||
|
|
||||||
|
$result = $this->subscriber->sendConfirmationEmail();
|
||||||
|
|
||||||
|
// email contains subscriber's lists
|
||||||
|
expect($result['body']['html'])->contains('<strong>Test segment</strong>');
|
||||||
|
// email contains activation link
|
||||||
|
expect($result['body']['html'])->contains('<a target="_blank" href="http://example.com">Click here to confirm your subscription.</a>');
|
||||||
|
}
|
||||||
|
|
||||||
|
function testItSetsErrorsWhenConfirmationEmailCannotBeSent() {
|
||||||
|
Mock::double('MailPoet\Mailer\Mailer', [
|
||||||
|
'__construct' => null,
|
||||||
|
'send' => function() {
|
||||||
|
throw new \Exception('send error');
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->subscriber->sendConfirmationEmail();
|
||||||
|
// error is set on the subscriber model object
|
||||||
|
expect($this->subscriber->getErrors()[0])->equals('send error');
|
||||||
|
}
|
||||||
|
|
||||||
function _after() {
|
function _after() {
|
||||||
ORM::raw_execute('TRUNCATE ' . Subscriber::$_table);
|
ORM::raw_execute('TRUNCATE ' . Subscriber::$_table);
|
||||||
ORM::raw_execute('TRUNCATE ' . Segment::$_table);
|
ORM::raw_execute('TRUNCATE ' . Segment::$_table);
|
||||||
|
Reference in New Issue
Block a user