Rename Send classes
[MAILPOET-1522]
This commit is contained in:
@ -7,8 +7,8 @@ use MailPoet\Models\Subscriber;
|
||||
use MailPoet\Models\SubscriberSegment;
|
||||
use MailPoet\Newsletter\Scheduler\Scheduler;
|
||||
use MailPoet\Subscribers\RequiredCustomFieldValidator;
|
||||
use MailPoet\Subscribers\SendConfirmationEmail;
|
||||
use MailPoet\Subscribers\SendNewSubscriberNotification;
|
||||
use MailPoet\Subscribers\ConfirmationEmailMailer;
|
||||
use MailPoet\Subscribers\NewSubscriberNotificationMailer;
|
||||
use MailPoet\Subscribers\Source;
|
||||
use MailPoet\Tasks\Sending;
|
||||
|
||||
@ -255,7 +255,7 @@ class API {
|
||||
}
|
||||
|
||||
protected function _sendConfirmationEmail(Subscriber $subscriber) {
|
||||
$sender = new SendConfirmationEmail();
|
||||
$sender = new ConfirmationEmailMailer();
|
||||
return $sender->sendConfirmationEmail($subscriber);
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ class API {
|
||||
}
|
||||
|
||||
private function sendSubscriberNotification(Subscriber $subscriber, array $segment_ids) {
|
||||
$sender = new SendNewSubscriberNotification();
|
||||
$sender = new NewSubscriberNotificationMailer();
|
||||
$sender->send($subscriber, Segment::whereIn('id', $segment_ids)->findMany());
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ use MailPoet\Models\Segment;
|
||||
use MailPoet\Models\Setting;
|
||||
use MailPoet\Models\Subscriber;
|
||||
use MailPoet\Settings\Pages;
|
||||
use MailPoet\Subscribers\SendNewSubscriberNotification;
|
||||
use MailPoet\Subscribers\NewSubscriberNotificationMailer;
|
||||
|
||||
class Reporter {
|
||||
|
||||
@ -48,7 +48,7 @@ class Reporter {
|
||||
'Newsletter task scheduler (cron)' => $isCronTriggerMethodWP ? 'visitors' : 'script',
|
||||
'Open and click tracking' => (boolean)Setting::getValue('tracking.enabled', false),
|
||||
'Premium key valid' => $checker->isPremiumKeyValid(),
|
||||
'New subscriber notifications' => SendNewSubscriberNotification::isDisabled(Setting::getValue(SendNewSubscriberNotification::SETTINGS_KEY)),
|
||||
'New subscriber notifications' => NewSubscriberNotificationMailer::isDisabled(Setting::getValue(NewSubscriberNotificationMailer::SETTINGS_KEY)),
|
||||
'Number of standard newsletters sent in last 3 months' => $newsletters['sent_newsletters'],
|
||||
'Number of active post notifications' => $newsletters['notifications_count'],
|
||||
'Number of active welcome emails' => $newsletters['welcome_newsletters_count'],
|
||||
|
@ -11,7 +11,7 @@ use MailPoet\Models\Subscriber;
|
||||
use MailPoet\Segments\WP;
|
||||
use MailPoet\Models\Setting;
|
||||
use MailPoet\Settings\Pages;
|
||||
use MailPoet\Subscribers\SendNewSubscriberNotification;
|
||||
use MailPoet\Subscribers\NewSubscriberNotificationMailer;
|
||||
use MailPoet\Subscribers\Source;
|
||||
use MailPoet\Util\Helpers;
|
||||
|
||||
@ -171,7 +171,7 @@ class Populator {
|
||||
));
|
||||
}
|
||||
|
||||
$subscriber_email_notification = Setting::getValue(SendNewSubscriberNotification::SETTINGS_KEY);
|
||||
$subscriber_email_notification = Setting::getValue(NewSubscriberNotificationMailer::SETTINGS_KEY);
|
||||
if(empty($subscriber_email_notification)) {
|
||||
$sender = Setting::getValue('sender', []);
|
||||
Setting::setValue('subscriber_email_notification', [
|
||||
|
@ -2,8 +2,8 @@
|
||||
namespace MailPoet\Models;
|
||||
use MailPoet\Mailer\Mailer;
|
||||
use MailPoet\Newsletter\Scheduler\Scheduler;
|
||||
use MailPoet\Subscribers\SendConfirmationEmail;
|
||||
use MailPoet\Subscribers\SendNewSubscriberNotification;
|
||||
use MailPoet\Subscribers\ConfirmationEmailMailer;
|
||||
use MailPoet\Subscribers\NewSubscriberNotificationMailer;
|
||||
use MailPoet\Subscribers\Source;
|
||||
use MailPoet\Util\Helpers;
|
||||
use MailPoet\Subscription;
|
||||
@ -152,11 +152,11 @@ class Subscriber extends Model {
|
||||
// link subscriber to segments
|
||||
SubscriberSegment::subscribeToSegments($subscriber, $segment_ids);
|
||||
|
||||
$sender = new SendConfirmationEmail();
|
||||
$sender = new ConfirmationEmailMailer();
|
||||
$sender->sendConfirmationEmail($subscriber);
|
||||
|
||||
if($subscriber->status === self::STATUS_SUBSCRIBED) {
|
||||
$sender = new SendNewSubscriberNotification();
|
||||
$sender = new NewSubscriberNotificationMailer();
|
||||
$sender->send($subscriber, Segment::whereIn('id', $segment_ids)->findMany());
|
||||
|
||||
Scheduler::scheduleSubscriberWelcomeNotification(
|
||||
|
@ -8,7 +8,7 @@ use MailPoet\Models\Subscriber;
|
||||
use MailPoet\Subscription\Url;
|
||||
use MailPoet\Util\Helpers;
|
||||
|
||||
class SendConfirmationEmail {
|
||||
class ConfirmationEmailMailer {
|
||||
|
||||
/** @var Mailer */
|
||||
private $mailer;
|
@ -7,7 +7,7 @@ use MailPoet\Models\Segment;
|
||||
use MailPoet\Models\Setting;
|
||||
use MailPoet\Models\Subscriber;
|
||||
|
||||
class SendNewSubscriberNotification {
|
||||
class NewSubscriberNotificationMailer {
|
||||
|
||||
const SENDER_EMAIL_PREFIX = 'wordpress@';
|
||||
const SETTINGS_KEY = 'subscriber_email_notification';
|
||||
@ -44,7 +44,7 @@ class SendNewSubscriberNotification {
|
||||
* @throws \Exception
|
||||
*/
|
||||
function send(Subscriber $subscriber, array $segments) {
|
||||
$settings = Setting::getValue(SendNewSubscriberNotification::SETTINGS_KEY);
|
||||
$settings = Setting::getValue(NewSubscriberNotificationMailer::SETTINGS_KEY);
|
||||
if($this->isDisabled($settings)) {
|
||||
return;
|
||||
}
|
@ -8,7 +8,7 @@ use MailPoet\Models\CustomField;
|
||||
use MailPoet\Models\Setting;
|
||||
use MailPoet\Models\Segment;
|
||||
use MailPoet\Newsletter\Scheduler\Scheduler;
|
||||
use MailPoet\Subscribers\SendNewSubscriberNotification;
|
||||
use MailPoet\Subscribers\NewSubscriberNotificationMailer;
|
||||
use MailPoet\Util\Helpers;
|
||||
use MailPoet\Util\Url as UrlHelper;
|
||||
use MailPoet\Form\Renderer as FormRenderer;
|
||||
@ -23,7 +23,7 @@ class Pages {
|
||||
private $action;
|
||||
private $data;
|
||||
private $subscriber;
|
||||
/** @var SendNewSubscriberNotification */
|
||||
/** @var NewSubscriberNotificationMailer */
|
||||
private $new_subscriber_notification_sender;
|
||||
|
||||
function __construct($action = false, $data = array(), $init_shortcodes = false, $init_page_filters = false, $new_subscriber_notification_sender = null) {
|
||||
@ -35,7 +35,7 @@ class Pages {
|
||||
if($new_subscriber_notification_sender) {
|
||||
$this->new_subscriber_notification_sender = $new_subscriber_notification_sender;
|
||||
} else {
|
||||
$this->new_subscriber_notification_sender = new SendNewSubscriberNotification();
|
||||
$this->new_subscriber_notification_sender = new NewSubscriberNotificationMailer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ use MailPoet\Models\Segment;
|
||||
use MailPoet\Models\Subscriber;
|
||||
use MailPoet\Models\SubscriberSegment;
|
||||
|
||||
class SendConfirmationEmailTest extends \MailPoetTest {
|
||||
class ConfirmationEmailMailerTest extends \MailPoetTest {
|
||||
|
||||
function testItSendsConfirmationEmail() {
|
||||
Mock::double('MailPoet\Subscription\Url', [
|
||||
@ -30,7 +30,7 @@ class SendConfirmationEmailTest extends \MailPoetTest {
|
||||
}),
|
||||
], $this);
|
||||
|
||||
$sender = new SendConfirmationEmail($mailer);
|
||||
$sender = new ConfirmationEmailMailer($mailer);
|
||||
|
||||
|
||||
$segment = Segment::createOrUpdate(
|
||||
@ -61,7 +61,7 @@ class SendConfirmationEmailTest extends \MailPoetTest {
|
||||
}),
|
||||
], $this);
|
||||
|
||||
$sender = new SendConfirmationEmail($mailer);
|
||||
$sender = new ConfirmationEmailMailer($mailer);
|
||||
|
||||
$sender->sendConfirmationEmail($subscriber);
|
||||
// error is set on the subscriber model object
|
@ -9,7 +9,7 @@ use MailPoet\Models\Segment;
|
||||
use MailPoet\Models\Setting;
|
||||
use MailPoet\Models\Subscriber;
|
||||
|
||||
class SendNewSubscriberNotificationTest extends \MailPoetTest {
|
||||
class NewSubscriberNotificationMailerTest extends \MailPoetTest {
|
||||
|
||||
/** @var Subscriber */
|
||||
private $subscriber;
|
||||
@ -26,36 +26,36 @@ class SendNewSubscriberNotificationTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
function testItDoesNotSendIfNoSettings() {
|
||||
Setting::setValue(SendNewSubscriberNotification::SETTINGS_KEY, null);
|
||||
Setting::setValue(NewSubscriberNotificationMailer::SETTINGS_KEY, null);
|
||||
$mailer = Stub::makeEmpty(Mailer::class, ['getSenderNameAndAddress' => Expected::never()], $this);
|
||||
$service = new SendNewSubscriberNotification($mailer);
|
||||
$service = new NewSubscriberNotificationMailer($mailer);
|
||||
$service->send($this->subscriber, $this->segments);
|
||||
}
|
||||
|
||||
function testItDoesNotSendIfSettingsDoesNotHaveEnabled() {
|
||||
Setting::setValue(SendNewSubscriberNotification::SETTINGS_KEY, []);
|
||||
Setting::setValue(NewSubscriberNotificationMailer::SETTINGS_KEY, []);
|
||||
$mailer = Stub::makeEmpty(Mailer::class, ['getSenderNameAndAddress' => Expected::never()], $this);
|
||||
$service = new SendNewSubscriberNotification($mailer);
|
||||
$service = new NewSubscriberNotificationMailer($mailer);
|
||||
$service->send($this->subscriber, $this->segments);
|
||||
}
|
||||
|
||||
|
||||
function testItDoesNotSendIfSettingsDoesNotHaveAddress() {
|
||||
Setting::setValue(SendNewSubscriberNotification::SETTINGS_KEY, ['enabled' => false]);
|
||||
Setting::setValue(NewSubscriberNotificationMailer::SETTINGS_KEY, ['enabled' => false]);
|
||||
$mailer = Stub::makeEmpty(Mailer::class, ['getSenderNameAndAddress' => Expected::never()], $this);
|
||||
$service = new SendNewSubscriberNotification($mailer);
|
||||
$service = new NewSubscriberNotificationMailer($mailer);
|
||||
$service->send($this->subscriber, $this->segments);
|
||||
}
|
||||
|
||||
function testItDoesNotSendIfDisabled() {
|
||||
Setting::setValue(SendNewSubscriberNotification::SETTINGS_KEY, ['enabled' => false, 'address' => 'a@b.c']);
|
||||
Setting::setValue(NewSubscriberNotificationMailer::SETTINGS_KEY, ['enabled' => false, 'address' => 'a@b.c']);
|
||||
$mailer = Stub::makeEmpty(Mailer::class, ['getSenderNameAndAddress' => Expected::never()], $this);
|
||||
$service = new SendNewSubscriberNotification($mailer);
|
||||
$service = new NewSubscriberNotificationMailer($mailer);
|
||||
$service->send($this->subscriber, $this->segments);
|
||||
}
|
||||
|
||||
function testItSends() {
|
||||
Setting::setValue(SendNewSubscriberNotification::SETTINGS_KEY, ['enabled' => true, 'address' => 'a@b.c']);
|
||||
Setting::setValue(NewSubscriberNotificationMailer::SETTINGS_KEY, ['enabled' => true, 'address' => 'a@b.c']);
|
||||
|
||||
$mailer = Stub::makeEmpty(Mailer::class, [
|
||||
'getSenderNameAndAddress' =>
|
||||
@ -79,7 +79,7 @@ class SendNewSubscriberNotificationTest extends \MailPoetTest {
|
||||
}),
|
||||
], $this);
|
||||
|
||||
$service = new SendNewSubscriberNotification($mailer);
|
||||
$service = new NewSubscriberNotificationMailer($mailer);
|
||||
$service->send($this->subscriber, $this->segments);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ use MailPoet\Models\Segment;
|
||||
use MailPoet\Models\SendingQueue;
|
||||
use MailPoet\Models\Subscriber;
|
||||
use MailPoet\Models\SubscriberSegment;
|
||||
use MailPoet\Subscribers\SendNewSubscriberNotification;
|
||||
use MailPoet\Subscribers\NewSubscriberNotificationMailer;
|
||||
use MailPoet\Subscription\Pages;
|
||||
|
||||
class PagesTest extends \MailPoetTest {
|
||||
@ -29,7 +29,7 @@ class PagesTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
function testItConfirmsSubscription() {
|
||||
$new_subscriber_notification_sender = Stub::makeEmpty(SendNewSubscriberNotification::class, ['send' => Stub\Expected::once()]);
|
||||
$new_subscriber_notification_sender = Stub::makeEmpty(NewSubscriberNotificationMailer::class, ['send' => Stub\Expected::once()]);
|
||||
$subscription = new Pages($action = false, $this->test_data, false, false, $new_subscriber_notification_sender);
|
||||
$subscription->confirm();
|
||||
$confirmed_subscriber = Subscriber::findOne($this->subscriber->id);
|
||||
@ -37,7 +37,7 @@ class PagesTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
function testItDoesNotConfirmSubscriptionOnDuplicateAttempt() {
|
||||
$new_subscriber_notification_sender = Stub::makeEmpty(SendNewSubscriberNotification::class, ['send' => Stub\Expected::once()]);
|
||||
$new_subscriber_notification_sender = Stub::makeEmpty(NewSubscriberNotificationMailer::class, ['send' => Stub\Expected::once()]);
|
||||
$subscriber = $this->subscriber;
|
||||
$subscriber->status = Subscriber::STATUS_SUBSCRIBED;
|
||||
$subscriber->save();
|
||||
@ -46,7 +46,7 @@ class PagesTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
function testItSendsWelcomeNotificationUponConfirmingSubscription() {
|
||||
$new_subscriber_notification_sender = Stub::makeEmpty(SendNewSubscriberNotification::class, ['send' => Stub\Expected::once()]);
|
||||
$new_subscriber_notification_sender = Stub::makeEmpty(NewSubscriberNotificationMailer::class, ['send' => Stub\Expected::once()]);
|
||||
$subscription = new Pages($action = false, $this->test_data, false, false, $new_subscriber_notification_sender);
|
||||
// create segment
|
||||
$segment = Segment::create();
|
||||
|
Reference in New Issue
Block a user