Refactor authorized emails validation from Bridge to Controller
[MAILPOET-2022]
This commit is contained in:
committed by
M. Shull
parent
f3d8ac4c7d
commit
f86c0c9612
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace MailPoet\Test\Services;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Codeception\Stub\Expected;
|
||||
use Codeception\Util\Stub;
|
||||
use MailPoet\Mailer\Mailer;
|
||||
use MailPoet\Models\Setting;
|
||||
@@ -291,68 +289,6 @@ class BridgeTest extends \MailPoetTest {
|
||||
$wp->removeFilter('mailpoet_bridge_api_request_timeout', $filter);
|
||||
}
|
||||
|
||||
function testItResetsAuthorisedEmailsErrorIfMssIsNotActive() {
|
||||
$this->settings->set('installed_at', new Carbon());
|
||||
$this->settings->set(Bridge::AUTHORIZED_EMAIL_ADDRESSES_ERROR_SETTING_NAME, 'Error');
|
||||
$api = $this->make(API::class, ['getAuthorizedEmailAddresses' => Expected::never()]);
|
||||
$this->bridge->api = $api;
|
||||
$this->bridge->checkAuthorizedEmailAddresses();
|
||||
expect($this->settings->get(Bridge::AUTHORIZED_EMAIL_ADDRESSES_ERROR_SETTING_NAME))->null();
|
||||
}
|
||||
|
||||
function testItResetsAuthorisedEmailsErrorIfIntalationDateIsOlderThanAuthEmailsFeature() {
|
||||
$this->settings->set('installed_at', '2018-03-04');
|
||||
$this->setMailPoetSendingMethod();
|
||||
$api = $this->make(API::class, ['getAuthorizedEmailAddresses' => Expected::never()]);
|
||||
$this->bridge->api = $api;
|
||||
$this->bridge->checkAuthorizedEmailAddresses();
|
||||
expect($this->settings->get(Bridge::AUTHORIZED_EMAIL_ADDRESSES_ERROR_SETTING_NAME))->null();
|
||||
}
|
||||
|
||||
function testItSetProperErrorForInvalidDefaultSender() {
|
||||
$this->settings->set('installed_at', new Carbon());
|
||||
$this->settings->set('sender.address', 'invalid@email.com');
|
||||
$this->settings->set('signup_confirmation.from.address', 'auth@email.com');
|
||||
$this->setMailPoetSendingMethod();
|
||||
$api = $this->make(API::class, ['getAuthorizedEmailAddresses' => Expected::once(['auth@email.com'])]);
|
||||
$this->bridge->api = $api;
|
||||
$this->bridge->checkAuthorizedEmailAddresses();
|
||||
expect($this->settings->get(Bridge::AUTHORIZED_EMAIL_ADDRESSES_ERROR_SETTING_NAME))->equals(['invalid_sender_address' => 'invalid@email.com']);
|
||||
}
|
||||
|
||||
function testItSetProperErrorForInvalidConfirmationSender() {
|
||||
$this->settings->set('installed_at', new Carbon());
|
||||
$this->settings->set('sender.address', 'auth@email.com');
|
||||
$this->settings->set('signup_confirmation.from.address', 'invalid@email.com');
|
||||
$this->setMailPoetSendingMethod();
|
||||
$api = $this->make(API::class, ['getAuthorizedEmailAddresses' => Expected::once(['auth@email.com'])]);
|
||||
$this->bridge->api = $api;
|
||||
$this->bridge->checkAuthorizedEmailAddresses();
|
||||
expect($this->settings->get(Bridge::AUTHORIZED_EMAIL_ADDRESSES_ERROR_SETTING_NAME))->equals(['invalid_confirmation_address' => 'invalid@email.com']);
|
||||
}
|
||||
|
||||
function testItSetProperErrorForConfirmationAddressAndDefaultSender() {
|
||||
$this->settings->set('installed_at', new Carbon());
|
||||
$this->settings->set('sender.address', 'invalid@email.com');
|
||||
$this->settings->set('signup_confirmation.from.address', 'invalid@email.com');
|
||||
$this->setMailPoetSendingMethod();
|
||||
$api = $this->make(API::class, ['getAuthorizedEmailAddresses' => Expected::once(['auth@email.com'])]);
|
||||
$this->bridge->api = $api;
|
||||
$this->bridge->checkAuthorizedEmailAddresses();
|
||||
expect($this->settings->get(Bridge::AUTHORIZED_EMAIL_ADDRESSES_ERROR_SETTING_NAME))->equals(['invalid_sender_address' => 'invalid@email.com', 'invalid_confirmation_address' => 'invalid@email.com']);
|
||||
}
|
||||
|
||||
function testItSetEmptyErrorWhenBothAdressesAreCorrect() {
|
||||
$this->settings->set('installed_at', new Carbon());
|
||||
$this->settings->set('sender.address', 'auth@email.com');
|
||||
$this->settings->set('signup_confirmation.from.address', 'auth@email.com');
|
||||
$this->setMailPoetSendingMethod();
|
||||
$api = $this->make(API::class, ['getAuthorizedEmailAddresses' => Expected::once(['auth@email.com'])]);
|
||||
$this->bridge->api = $api;
|
||||
$this->bridge->checkAuthorizedEmailAddresses();
|
||||
expect($this->settings->get(Bridge::AUTHORIZED_EMAIL_ADDRESSES_ERROR_SETTING_NAME))->null();
|
||||
}
|
||||
|
||||
private function setMailPoetSendingMethod() {
|
||||
$this->settings->set(
|
||||
Mailer::MAILER_CONFIG_SETTING_NAME,
|
||||
|
Reference in New Issue
Block a user