Make tests more obvious
[MAILPOET-1014]
This commit is contained in:
@ -4,6 +4,7 @@ namespace MailPoet\Test\API\JSON\v1;
|
|||||||
use Codeception\Util\Fixtures;
|
use Codeception\Util\Fixtures;
|
||||||
use MailPoet\API\JSON\v1\Subscribers;
|
use MailPoet\API\JSON\v1\Subscribers;
|
||||||
use MailPoet\API\JSON\Response as APIResponse;
|
use MailPoet\API\JSON\Response as APIResponse;
|
||||||
|
use MailPoet\Form\Util\FieldNameObfuscator;
|
||||||
use MailPoet\Models\Form;
|
use MailPoet\Models\Form;
|
||||||
use MailPoet\Models\Subscriber;
|
use MailPoet\Models\Subscriber;
|
||||||
use MailPoet\Models\Segment;
|
use MailPoet\Models\Segment;
|
||||||
@ -11,6 +12,8 @@ use MailPoet\Models\Setting;
|
|||||||
|
|
||||||
class SubscribersTest extends \MailPoetTest {
|
class SubscribersTest extends \MailPoetTest {
|
||||||
function _before() {
|
function _before() {
|
||||||
|
$obfuscator = new FieldNameObfuscator();
|
||||||
|
$this->obfuscatedEmail = $obfuscator->obfuscate('email');
|
||||||
$this->segment_1 = Segment::createOrUpdate(array('name' => 'Segment 1'));
|
$this->segment_1 = Segment::createOrUpdate(array('name' => 'Segment 1'));
|
||||||
$this->segment_2 = Segment::createOrUpdate(array('name' => 'Segment 2'));
|
$this->segment_2 = Segment::createOrUpdate(array('name' => 'Segment 2'));
|
||||||
|
|
||||||
@ -416,7 +419,7 @@ class SubscribersTest extends \MailPoetTest {
|
|||||||
function testItCannotSubscribeWithoutSegmentsIfTheyAreSelectedByUser() {
|
function testItCannotSubscribeWithoutSegmentsIfTheyAreSelectedByUser() {
|
||||||
$router = new Subscribers();
|
$router = new Subscribers();
|
||||||
$response = $router->subscribe(array(
|
$response = $router->subscribe(array(
|
||||||
'form_field_ZW1haWw=' => 'toto@mailpoet.com',
|
$this->obfuscatedEmail => 'toto@mailpoet.com',
|
||||||
'form_id' => $this->form->id
|
'form_id' => $this->form->id
|
||||||
// no segments specified
|
// no segments specified
|
||||||
));
|
));
|
||||||
@ -428,7 +431,7 @@ class SubscribersTest extends \MailPoetTest {
|
|||||||
function testItCanSubscribe() {
|
function testItCanSubscribe() {
|
||||||
$router = new Subscribers();
|
$router = new Subscribers();
|
||||||
$response = $router->subscribe(array(
|
$response = $router->subscribe(array(
|
||||||
'form_field_ZW1haWw=' => 'toto@mailpoet.com',
|
$this->obfuscatedEmail => 'toto@mailpoet.com',
|
||||||
'form_id' => $this->form->id,
|
'form_id' => $this->form->id,
|
||||||
'segments' => array($this->segment_1->id, $this->segment_2->id)
|
'segments' => array($this->segment_1->id, $this->segment_2->id)
|
||||||
));
|
));
|
||||||
@ -443,7 +446,7 @@ class SubscribersTest extends \MailPoetTest {
|
|||||||
|
|
||||||
$router = new Subscribers();
|
$router = new Subscribers();
|
||||||
$response = $router->subscribe(array(
|
$response = $router->subscribe(array(
|
||||||
'form_field_ZW1haWw=' => 'toto@mailpoet.com',
|
$this->obfuscatedEmail => 'toto@mailpoet.com',
|
||||||
'form_id' => $this->form->id
|
'form_id' => $this->form->id
|
||||||
// no segments specified
|
// no segments specified
|
||||||
));
|
));
|
||||||
@ -465,7 +468,7 @@ class SubscribersTest extends \MailPoetTest {
|
|||||||
|
|
||||||
$router = new Subscribers();
|
$router = new Subscribers();
|
||||||
$response = $router->subscribe(array(
|
$response = $router->subscribe(array(
|
||||||
'form_field_ZW1haWw=' => 'toto@mailpoet.com',
|
$this->obfuscatedEmail => 'toto@mailpoet.com',
|
||||||
'form_id' => $this->form->id,
|
'form_id' => $this->form->id,
|
||||||
'segments' => array($this->segment_1->id, $this->segment_2->id)
|
'segments' => array($this->segment_1->id, $this->segment_2->id)
|
||||||
));
|
));
|
||||||
@ -477,7 +480,7 @@ class SubscribersTest extends \MailPoetTest {
|
|||||||
function testItCanFilterOutNonFormFieldsWhenSubscribing() {
|
function testItCanFilterOutNonFormFieldsWhenSubscribing() {
|
||||||
$router = new Subscribers();
|
$router = new Subscribers();
|
||||||
$response = $router->subscribe(array(
|
$response = $router->subscribe(array(
|
||||||
'form_field_ZW1haWw=' => 'toto@mailpoet.com',
|
$this->obfuscatedEmail => 'toto@mailpoet.com',
|
||||||
'form_id' => $this->form->id,
|
'form_id' => $this->form->id,
|
||||||
'segments' => array($this->segment_1->id, $this->segment_2->id),
|
'segments' => array($this->segment_1->id, $this->segment_2->id),
|
||||||
// exists in table and in the form
|
// exists in table and in the form
|
||||||
@ -498,14 +501,14 @@ class SubscribersTest extends \MailPoetTest {
|
|||||||
|
|
||||||
$router = new Subscribers();
|
$router = new Subscribers();
|
||||||
$response = $router->subscribe(array(
|
$response = $router->subscribe(array(
|
||||||
'form_field_ZW1haWw=' => 'toto@mailpoet.com',
|
$this->obfuscatedEmail => 'toto@mailpoet.com',
|
||||||
'form_id' => $this->form->id,
|
'form_id' => $this->form->id,
|
||||||
'segments' => array($this->segment_1->id, $this->segment_2->id)
|
'segments' => array($this->segment_1->id, $this->segment_2->id)
|
||||||
));
|
));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$response = $router->subscribe(array(
|
$response = $router->subscribe(array(
|
||||||
'form_field_ZW1haWw=' => 'tata@mailpoet.com',
|
$this->obfuscatedEmail => 'tata@mailpoet.com',
|
||||||
'form_id' => $this->form->id,
|
'form_id' => $this->form->id,
|
||||||
'segments' => array($this->segment_1->id, $this->segment_2->id)
|
'segments' => array($this->segment_1->id, $this->segment_2->id)
|
||||||
));
|
));
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
namespace MailPoet\Test\Subscription;
|
namespace MailPoet\Test\Subscription;
|
||||||
|
|
||||||
use AspectMock\Test as Mock;
|
use AspectMock\Test as Mock;
|
||||||
|
use MailPoet\Form\Util\FieldNameObfuscator;
|
||||||
use MailPoet\Models\Form as FormModel;
|
use MailPoet\Models\Form as FormModel;
|
||||||
use MailPoet\Models\Segment as SegmentModel;
|
use MailPoet\Models\Segment as SegmentModel;
|
||||||
use MailPoet\Models\Setting as SettingModel;
|
use MailPoet\Models\Setting as SettingModel;
|
||||||
@ -31,11 +32,13 @@ class FormTest extends \MailPoetTest {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
$obfuscator = new FieldNameObfuscator();
|
||||||
|
$obfuscatedEmail = $obfuscator->obfuscate('email');
|
||||||
$this->request_data = array(
|
$this->request_data = array(
|
||||||
'action' => 'mailpoet_subscription_form',
|
'action' => 'mailpoet_subscription_form',
|
||||||
'data' => array(
|
'data' => array(
|
||||||
'form_id' => $this->form->id,
|
'form_id' => $this->form->id,
|
||||||
'form_field_ZW1haWw=' => $this->testEmail
|
$obfuscatedEmail => $this->testEmail
|
||||||
),
|
),
|
||||||
'token' => Security::generateToken(),
|
'token' => Security::generateToken(),
|
||||||
'api_version' => 'v1',
|
'api_version' => 'v1',
|
||||||
|
Reference in New Issue
Block a user