Refactor getUnsubscribeUrl to instance method
[MAILPOET-2381]
This commit is contained in:
committed by
Jack Kitterhing
parent
4e75f8883e
commit
d90d5c6385
@ -60,7 +60,8 @@ class Links {
|
||||
$data
|
||||
);
|
||||
} else {
|
||||
$url = Url::getUnsubscribeUrl($subscriber);
|
||||
$subscription_url_factory = Url::getInstance();
|
||||
$url = $subscription_url_factory->getUnsubscribeUrl($subscriber);
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class Link {
|
||||
case 'subscription_unsubscribe_url':
|
||||
return self::processUrl(
|
||||
$shortcode_details['action'],
|
||||
SubscriptionUrl::getUnsubscribeUrl($wp_user_preview ? null : $subscriber),
|
||||
$subscription_url_factory->getUnsubscribeUrl($wp_user_preview ? null : $subscriber),
|
||||
$queue,
|
||||
$wp_user_preview
|
||||
);
|
||||
@ -83,7 +83,7 @@ class Link {
|
||||
$unsubscribe_event = new Unsubscribes();
|
||||
$unsubscribe_event->track($newsletter->id, $subscriber->id, $queue->id);
|
||||
}
|
||||
$url = SubscriptionUrl::getUnsubscribeUrl($subscriber);
|
||||
$url = $subscription_url_factory->getUnsubscribeUrl($subscriber);
|
||||
break;
|
||||
case 'subscription_manage_url':
|
||||
$url = $subscription_url_factory->getManageUrl($subscriber);
|
||||
|
@ -45,8 +45,8 @@ class Url {
|
||||
return self::getSubscriptionUrl($post, 'manage', $subscriber);
|
||||
}
|
||||
|
||||
static function getUnsubscribeUrl(Subscriber $subscriber = null) {
|
||||
$post = self::getPost(self::getSetting('subscription.pages.unsubscribe'));
|
||||
function getUnsubscribeUrl(Subscriber $subscriber = null) {
|
||||
$post = self::getPost($this->settings->get('subscription.pages.unsubscribe'));
|
||||
return self::getSubscriptionUrl($post, 'unsubscribe', $subscriber);
|
||||
}
|
||||
|
||||
@ -110,9 +110,4 @@ class Url {
|
||||
$pages = SettingsPages::getMailPoetPages();
|
||||
return reset($pages);
|
||||
}
|
||||
|
||||
static private function getSetting($key) {
|
||||
$setting = new SettingsController();
|
||||
return $setting->get($key);
|
||||
}
|
||||
}
|
||||
|
@ -805,7 +805,7 @@ class NewslettersTest extends \MailPoetTest {
|
||||
function testItCanSendAPreview() {
|
||||
|
||||
$subscriber = 'test@subscriber.com';
|
||||
$unsubscribeLink = SubscriptionUrl::getUnsubscribeUrl(null);
|
||||
$unsubscribeLink = $this->subscription_url_factory->getUnsubscribeUrl(null);
|
||||
$manageLink = $this->subscription_url_factory->getManageUrl(null);
|
||||
$viewInBrowserLink = Url::getViewInBrowserUrl(null, $this->newsletter, false, false, true);
|
||||
$mailerMetaInfo = new MetaInfo;
|
||||
|
@ -97,7 +97,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
private function getDirectUnsubscribeURL() {
|
||||
return Url::getUnsubscribeUrl($this->subscriber);
|
||||
return Url::getInstance()->getUnsubscribeUrl($this->subscriber);
|
||||
}
|
||||
|
||||
private function getTrackedUnsubscribeURL() {
|
||||
|
@ -302,7 +302,7 @@ class ShortcodesTest extends \MailPoetTest {
|
||||
'[link:newsletter_view_in_browser_url]',
|
||||
];
|
||||
$links = [
|
||||
SubscriptionUrl::getUnsubscribeUrl(null),
|
||||
$this->subscription_url_factory->getUnsubscribeUrl(null),
|
||||
$this->subscription_url_factory->getManageUrl(null),
|
||||
NewsletterUrl::getViewInBrowserUrl(null, $this->newsletter, false, false, true),
|
||||
];
|
||||
|
@ -41,7 +41,7 @@ class UrlTest extends \MailPoetTest {
|
||||
expect($url)->contains('action=captcha');
|
||||
expect($url)->contains('endpoint=subscription');
|
||||
|
||||
$url = Url::getUnsubscribeUrl(null);
|
||||
$url = $this->url->getUnsubscribeUrl(null);
|
||||
expect($url)->notNull();
|
||||
expect($url)->contains('action=unsubscribe');
|
||||
expect($url)->contains('endpoint=subscription');
|
||||
@ -99,7 +99,7 @@ class UrlTest extends \MailPoetTest {
|
||||
|
||||
function testItReturnsTheUnsubscribeUrl() {
|
||||
// preview
|
||||
$url = Url::getUnsubscribeUrl(null);
|
||||
$url = $this->url->getUnsubscribeUrl(null);
|
||||
expect($url)->notNull();
|
||||
expect($url)->contains('action=unsubscribe');
|
||||
expect($url)->contains('endpoint=subscription');
|
||||
@ -108,7 +108,7 @@ class UrlTest extends \MailPoetTest {
|
||||
$subscriber = Subscriber::createOrUpdate([
|
||||
'email' => 'john@mailpoet.com',
|
||||
]);
|
||||
$url = Url::getUnsubscribeUrl($subscriber);
|
||||
$url = $this->url->getUnsubscribeUrl($subscriber);
|
||||
expect($url)->contains('action=unsubscribe');
|
||||
expect($url)->contains('endpoint=subscription');
|
||||
|
||||
|
Reference in New Issue
Block a user