- Adds new models: CustomFields and SubscriberCustomField + tests
- Adjusts DB Migrator, Initializer class - Adjusts Subscribers model tests Closes #159
This commit is contained in:
@@ -8,7 +8,7 @@ if(!defined('ABSPATH')) exit;
|
|||||||
|
|
||||||
class Initializer {
|
class Initializer {
|
||||||
function __construct($params = array(
|
function __construct($params = array(
|
||||||
'file' => '',
|
'file' => '',
|
||||||
'version' => '1.0.0'
|
'version' => '1.0.0'
|
||||||
)) {
|
)) {
|
||||||
Env::init($params['file'], $params['version']);
|
Env::init($params['file'], $params['version']);
|
||||||
@@ -40,6 +40,8 @@ class Initializer {
|
|||||||
$segments = Env::$db_prefix . 'segments';
|
$segments = Env::$db_prefix . 'segments';
|
||||||
$subscriber_segment = Env::$db_prefix . 'subscriber_segment';
|
$subscriber_segment = Env::$db_prefix . 'subscriber_segment';
|
||||||
$newsletter_segment = Env::$db_prefix . 'newsletter_segment';
|
$newsletter_segment = Env::$db_prefix . 'newsletter_segment';
|
||||||
|
$custom_fields = Env::$db_prefix . 'custom_fields';
|
||||||
|
$subscriber_custom_field = Env::$db_prefix . 'subscriber_custom_field';
|
||||||
|
|
||||||
define('MP_SUBSCRIBERS_TABLE', $subscribers);
|
define('MP_SUBSCRIBERS_TABLE', $subscribers);
|
||||||
define('MP_SETTINGS_TABLE', $settings);
|
define('MP_SETTINGS_TABLE', $settings);
|
||||||
@@ -48,6 +50,8 @@ class Initializer {
|
|||||||
define('MP_SUBSCRIBER_SEGMENT_TABLE', $subscriber_segment);
|
define('MP_SUBSCRIBER_SEGMENT_TABLE', $subscriber_segment);
|
||||||
define('MP_NEWSLETTER_TEMPLATES_TABLE', $newsletter_templates);
|
define('MP_NEWSLETTER_TEMPLATES_TABLE', $newsletter_templates);
|
||||||
define('MP_NEWSLETTER_SEGMENT_TABLE', $newsletter_segment);
|
define('MP_NEWSLETTER_SEGMENT_TABLE', $newsletter_segment);
|
||||||
|
define('MP_CUSTOM_FIELDS_TABLE', $custom_fields);
|
||||||
|
define('MP_SUBSCRIBER_CUSTOM_FIELD_TABLE', $subscriber_custom_field);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupActivator() {
|
function setupActivator() {
|
||||||
@@ -82,4 +86,4 @@ class Initializer {
|
|||||||
$widget = new Widget();
|
$widget = new Widget();
|
||||||
$widget->init();
|
$widget->init();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -16,7 +16,9 @@ class Migrator {
|
|||||||
'newsletter_templates',
|
'newsletter_templates',
|
||||||
'segments',
|
'segments',
|
||||||
'subscriber_segment',
|
'subscriber_segment',
|
||||||
'newsletter_segment'
|
'newsletter_segment',
|
||||||
|
'custom_fields',
|
||||||
|
'subscriber_custom_field'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,6 +135,31 @@ class Migrator {
|
|||||||
return $this->sqlify(__FUNCTION__, $attributes);
|
return $this->sqlify(__FUNCTION__, $attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function custom_fields() {
|
||||||
|
$attributes = array(
|
||||||
|
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||||
|
'name varchar(90) NOT NULL,',
|
||||||
|
'created_at TIMESTAMP NOT NULL DEFAULT 0,',
|
||||||
|
'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
|
||||||
|
'PRIMARY KEY (id),',
|
||||||
|
'UNIQUE KEY name (name)'
|
||||||
|
);
|
||||||
|
return $this->sqlify(__FUNCTION__, $attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
function subscriber_custom_field() {
|
||||||
|
$attributes = array(
|
||||||
|
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||||
|
'subscriber_id mediumint(9) NOT NULL,',
|
||||||
|
'custom_field_id mediumint(9) NOT NULL,',
|
||||||
|
'value varchar(255) NOT NULL,',
|
||||||
|
'created_at TIMESTAMP NOT NULL DEFAULT 0,',
|
||||||
|
'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
|
||||||
|
'PRIMARY KEY (id)'
|
||||||
|
);
|
||||||
|
return $this->sqlify(__FUNCTION__, $attributes);
|
||||||
|
}
|
||||||
|
|
||||||
private function sqlify($model, $attributes) {
|
private function sqlify($model, $attributes) {
|
||||||
$table = $this->prefix . $model;
|
$table = $this->prefix . $model;
|
||||||
|
|
||||||
|
25
lib/Models/CustomField.php
Normal file
25
lib/Models/CustomField.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
namespace MailPoet\Models;
|
||||||
|
|
||||||
|
if(!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
|
class CustomField extends Model {
|
||||||
|
public static $_table = MP_CUSTOM_FIELDS_TABLE;
|
||||||
|
|
||||||
|
function __construct() {
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->addValidations('name', array(
|
||||||
|
'required' => __('You need to specify a name.')
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
function subscribers() {
|
||||||
|
return $this->has_many_through(
|
||||||
|
__NAMESPACE__ . '\Subscriber',
|
||||||
|
__NAMESPACE__ . '\SubscriberCustomField',
|
||||||
|
'custom_field_id',
|
||||||
|
'subscriber_id'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -132,6 +132,15 @@ class Subscriber extends Model {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function customFields() {
|
||||||
|
return $this->has_many_through(
|
||||||
|
__NAMESPACE__.'\CustomField',
|
||||||
|
__NAMESPACE__.'\SubscriberCustomField',
|
||||||
|
'subscriber_id',
|
||||||
|
'custom_field_id'
|
||||||
|
)->select_expr(MP_SUBSCRIBER_CUSTOM_FIELD_TABLE.'.value');
|
||||||
|
}
|
||||||
|
|
||||||
static function createOrUpdate($data = array()) {
|
static function createOrUpdate($data = array()) {
|
||||||
$subscriber = false;
|
$subscriber = false;
|
||||||
|
|
||||||
|
12
lib/Models/SubscriberCustomField.php
Normal file
12
lib/Models/SubscriberCustomField.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
namespace MailPoet\Models;
|
||||||
|
|
||||||
|
if(!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
|
class SubscriberCustomField extends Model {
|
||||||
|
public static $_table = MP_SUBSCRIBER_CUSTOM_FIELD_TABLE;
|
||||||
|
|
||||||
|
function __construct() {
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
}
|
@@ -7,10 +7,14 @@ require_once(getenv('WP_TEST_PATH') . '/wp-load.php');
|
|||||||
|
|
||||||
$console->writeln('Cleaning up database...');
|
$console->writeln('Cleaning up database...');
|
||||||
$models = array(
|
$models = array(
|
||||||
'Subscriber',
|
'CustomField',
|
||||||
'Setting',
|
|
||||||
'Newsletter',
|
'Newsletter',
|
||||||
|
'NewsletterSegment',
|
||||||
|
'NewsletterTemplate',
|
||||||
'Segment',
|
'Segment',
|
||||||
|
'Setting',
|
||||||
|
'Subscriber',
|
||||||
|
'SubscriberCustomField',
|
||||||
'SubscriberSegment'
|
'SubscriberSegment'
|
||||||
);
|
);
|
||||||
$destroy = function ($model) {
|
$destroy = function ($model) {
|
||||||
|
114
tests/unit/Models/CustomFieldCest.php
Normal file
114
tests/unit/Models/CustomFieldCest.php
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use MailPoet\Models\CustomField;
|
||||||
|
use MailPoet\Models\Subscriber;
|
||||||
|
use MailPoet\Models\SubscriberCustomField;
|
||||||
|
|
||||||
|
class CustomFieldCest {
|
||||||
|
function _before() {
|
||||||
|
$this->before_time = time();
|
||||||
|
$this->data = array(
|
||||||
|
'name' => 'city',
|
||||||
|
);
|
||||||
|
$this->customField = CustomField::create();
|
||||||
|
$this->customField->hydrate($this->data);
|
||||||
|
$this->saved = $this->customField->save();
|
||||||
|
$this->subscribersData = array(
|
||||||
|
array(
|
||||||
|
'first_name' => 'John',
|
||||||
|
'last_name' => 'Mailer',
|
||||||
|
'email' => 'john@mailpoet.com'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'first_name' => 'Mike',
|
||||||
|
'last_name' => 'Smith',
|
||||||
|
'email' => 'mike@maipoet.com'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function itCanBeCreated() {
|
||||||
|
expect($this->saved)->equals(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function itHasToBeValid() {
|
||||||
|
expect($this->saved)->equals(true);
|
||||||
|
$empty_model = CustomField::create();
|
||||||
|
expect($empty_model->save())->notEquals(true);
|
||||||
|
$validations = $empty_model->getValidationErrors();
|
||||||
|
expect(count($validations))->equals(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function itHasACreatedAtOnCreation() {
|
||||||
|
$customField = CustomField::where('name', $this->data['name'])
|
||||||
|
->findOne();
|
||||||
|
$time_difference = strtotime($customField->created_at) >= $this->before_time;
|
||||||
|
expect($time_difference)->equals(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function itHasAnUpdatedAtOnCreation() {
|
||||||
|
$customField = CustomField::where('name', $this->data['name'])
|
||||||
|
->findOne();
|
||||||
|
$time_difference = strtotime($customField->updated_at) >= $this->before_time;
|
||||||
|
expect($time_difference)->equals(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function itKeepsTheCreatedAtOnUpdate() {
|
||||||
|
$customField = CustomField::where('name', $this->data['name'])
|
||||||
|
->findOne();
|
||||||
|
$old_created_at = $customField->created_at;
|
||||||
|
$customField->name = 'new name';
|
||||||
|
$customField->save();
|
||||||
|
expect($old_created_at)->equals($customField->created_at);
|
||||||
|
}
|
||||||
|
|
||||||
|
function itUpdatesTheUpdatedAtOnUpdate() {
|
||||||
|
$customField = CustomField::where('name', $this->data['name'])
|
||||||
|
->findOne();
|
||||||
|
$update_time = time();
|
||||||
|
$customField->name = 'new name';
|
||||||
|
$customField->save();
|
||||||
|
$time_difference = strtotime($customField->updated_at) >= $update_time;
|
||||||
|
expect($time_difference)->equals(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function itCanHaveManySubscribers() {
|
||||||
|
foreach ($this->subscribersData as $data) {
|
||||||
|
$subscriber = Subscriber::create();
|
||||||
|
$subscriber->hydrate($data);
|
||||||
|
$subscriber->save();
|
||||||
|
$association = SubscriberCustomField::create();
|
||||||
|
$association->subscriber_id = $subscriber->id;
|
||||||
|
$association->custom_field_id = $this->customField->id;
|
||||||
|
$association->save();
|
||||||
|
}
|
||||||
|
$customField = CustomField::findOne($this->customField->id);
|
||||||
|
$subscribers = $customField->subscribers()
|
||||||
|
->findArray();
|
||||||
|
expect(count($subscribers))->equals(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
function itCanStoreCustomFieldValue() {
|
||||||
|
$subscriber = Subscriber::create();
|
||||||
|
$subscriber->hydrate($this->subscribersData[0]);
|
||||||
|
$subscriber->save();
|
||||||
|
$association = SubscriberCustomField::create();
|
||||||
|
$association->subscriber_id = $subscriber->id;
|
||||||
|
$association->custom_field_id = $this->customField->id;
|
||||||
|
$association->value = 'test';
|
||||||
|
$association->save();
|
||||||
|
$customField = CustomField::findOne($this->customField->id);
|
||||||
|
$subscriber = $customField->subscribers()
|
||||||
|
->findOne();
|
||||||
|
expect($subscriber->value)->equals($association->value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function _after() {
|
||||||
|
ORM::forTable(CustomField::$_table)
|
||||||
|
->deleteMany();
|
||||||
|
ORM::forTable(Subscriber::$_table)
|
||||||
|
->deleteMany();
|
||||||
|
ORM::forTable(SubscriberCustomField::$_table)
|
||||||
|
->deleteMany();
|
||||||
|
}
|
||||||
|
}
|
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
use MailPoet\Models\Subscriber;
|
use MailPoet\Models\CustomField;
|
||||||
use MailPoet\Models\Segment;
|
use MailPoet\Models\Segment;
|
||||||
|
use MailPoet\Models\Subscriber;
|
||||||
|
use MailPoet\Models\SubscriberCustomField;
|
||||||
use MailPoet\Models\SubscriberSegment;
|
use MailPoet\Models\SubscriberSegment;
|
||||||
|
|
||||||
class SubscriberCest {
|
class SubscriberCest {
|
||||||
@@ -11,7 +13,6 @@ class SubscriberCest {
|
|||||||
'last_name' => 'Mailer',
|
'last_name' => 'Mailer',
|
||||||
'email' => 'john@mailpoet.com'
|
'email' => 'john@mailpoet.com'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->subscriber = Subscriber::create();
|
$this->subscriber = Subscriber::create();
|
||||||
$this->subscriber->hydrate($this->data);
|
$this->subscriber->hydrate($this->data);
|
||||||
$this->saved = $this->subscriber->save();
|
$this->saved = $this->subscriber->save();
|
||||||
@@ -21,7 +22,7 @@ class SubscriberCest {
|
|||||||
expect($this->saved)->equals(true);
|
expect($this->saved)->equals(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function itHasAFirstName() {
|
function itHasFirstName() {
|
||||||
$subscriber =
|
$subscriber =
|
||||||
Subscriber::where('email', $this->data['email'])
|
Subscriber::where('email', $this->data['email'])
|
||||||
->findOne();
|
->findOne();
|
||||||
@@ -29,7 +30,7 @@ class SubscriberCest {
|
|||||||
->equals($this->data['first_name']);
|
->equals($this->data['first_name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function itHasALastName() {
|
function itHasLastName() {
|
||||||
$subscriber =
|
$subscriber =
|
||||||
Subscriber::where('email', $this->data['email'])
|
Subscriber::where('email', $this->data['email'])
|
||||||
->findOne();
|
->findOne();
|
||||||
@@ -37,7 +38,7 @@ class SubscriberCest {
|
|||||||
->equals($this->data['last_name']);
|
->equals($this->data['last_name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function itHasAnEmail() {
|
function itHasEmail() {
|
||||||
$subscriber =
|
$subscriber =
|
||||||
Subscriber::where('email', $this->data['email'])
|
Subscriber::where('email', $this->data['email'])
|
||||||
->findOne();
|
->findOne();
|
||||||
@@ -52,59 +53,60 @@ class SubscriberCest {
|
|||||||
expect($saved)->notEquals(true);
|
expect($saved)->notEquals(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function itHasAStatus() {
|
function itHasStatus() {
|
||||||
$subscriber =
|
$subscriber =
|
||||||
Subscriber::where('email', $this->data['email'])
|
Subscriber::where('email', $this->data['email'])
|
||||||
->findOne();
|
->findOne();
|
||||||
|
|
||||||
expect($subscriber->status)->equals('unconfirmed');
|
expect($subscriber->status)->equals('unconfirmed');
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCanChangeStatus() {
|
function itCanChangeStatus() {
|
||||||
$subscriber = Subscriber::where('email', $this->data['email'])->findOne();
|
$subscriber = Subscriber::where('email', $this->data['email'])
|
||||||
|
->findOne();
|
||||||
$subscriber->status = 'subscribed';
|
$subscriber->status = 'subscribed';
|
||||||
expect($subscriber->save())->equals(true);
|
expect($subscriber->save())->equals(true);
|
||||||
|
|
||||||
$subscriber_updated = Subscriber::where(
|
$subscriber_updated = Subscriber::where(
|
||||||
'email',
|
'email',
|
||||||
$this->data['email']
|
$this->data['email']
|
||||||
)->findOne();
|
)
|
||||||
|
->findOne();
|
||||||
expect($subscriber_updated->status)->equals('subscribed');
|
expect($subscriber_updated->status)->equals('subscribed');
|
||||||
}
|
}
|
||||||
|
|
||||||
function itHasASearchFilter() {
|
function itHasSearchFilter() {
|
||||||
$subscriber = Subscriber::filter('search', 'john')->findOne();
|
$subscriber = Subscriber::filter('search', 'john')
|
||||||
|
->findOne();
|
||||||
expect($subscriber->first_name)->equals($this->data['first_name']);
|
expect($subscriber->first_name)->equals($this->data['first_name']);
|
||||||
|
$subscriber = Subscriber::filter('search', 'mailer')
|
||||||
$subscriber = Subscriber::filter('search', 'mailer')->findOne();
|
->findOne();
|
||||||
expect($subscriber->last_name)->equals($this->data['last_name']);
|
expect($subscriber->last_name)->equals($this->data['last_name']);
|
||||||
|
$subscriber = Subscriber::filter('search', 'mailpoet')
|
||||||
$subscriber = Subscriber::filter('search', 'mailpoet')->findOne();
|
->findOne();
|
||||||
expect($subscriber->email)->equals($this->data['email']);
|
expect($subscriber->email)->equals($this->data['email']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function itHasAGroupFilter() {
|
function itHasGroupFilter() {
|
||||||
$subscribers = Subscriber::filter('groupBy', 'unconfirmed')->findMany();
|
$subscribers = Subscriber::filter('groupBy', 'unconfirmed')
|
||||||
foreach($subscribers as $subscriber) {
|
->findMany();
|
||||||
|
foreach ($subscribers as $subscriber) {
|
||||||
expect($subscriber->status)->equals('unconfirmed');
|
expect($subscriber->status)->equals('unconfirmed');
|
||||||
}
|
}
|
||||||
|
$subscribers = Subscriber::filter('groupBy', 'subscribed')
|
||||||
$subscribers = Subscriber::filter('groupBy', 'subscribed')->findMany();
|
->findMany();
|
||||||
foreach($subscribers as $subscriber) {
|
foreach ($subscribers as $subscriber) {
|
||||||
expect($subscriber->status)->equals('subscribed');
|
expect($subscriber->status)->equals('subscribed');
|
||||||
}
|
}
|
||||||
|
$subscribers = Subscriber::filter('groupBy', 'unsubscribed')
|
||||||
$subscribers = Subscriber::filter('groupBy', 'unsubscribed')->findMany();
|
->findMany();
|
||||||
foreach($subscribers as $subscriber) {
|
foreach ($subscribers as $subscriber) {
|
||||||
expect($subscriber->status)->equals('unsubscribed');
|
expect($subscriber->status)->equals('unsubscribed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCanHaveASegment() {
|
function itCanHaveSegment() {
|
||||||
$segmentData = array(
|
$segmentData = array(
|
||||||
'name' => 'some name'
|
'name' => 'some name'
|
||||||
);
|
);
|
||||||
|
|
||||||
$segment = Segment::create();
|
$segment = Segment::create();
|
||||||
$segment->hydrate($segmentData);
|
$segment->hydrate($segmentData);
|
||||||
$segment->save();
|
$segment->save();
|
||||||
@@ -112,32 +114,46 @@ class SubscriberCest {
|
|||||||
$association->subscriber_id = $this->subscriber->id;
|
$association->subscriber_id = $this->subscriber->id;
|
||||||
$association->segment_id = $segment->id;
|
$association->segment_id = $segment->id;
|
||||||
$association->save();
|
$association->save();
|
||||||
|
|
||||||
$subscriber = Subscriber::findOne($this->subscriber->id);
|
$subscriber = Subscriber::findOne($this->subscriber->id);
|
||||||
$subscriberSegment = $subscriber->segments()->findOne();
|
$subscriberSegment = $subscriber->segments()
|
||||||
|
->findOne();
|
||||||
expect($subscriberSegment->id)->equals($segment->id);
|
expect($subscriberSegment->id)->equals($segment->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function itCanHaveCustomField() {
|
||||||
|
$customFieldData = array(
|
||||||
|
'name' => 'city'
|
||||||
|
);
|
||||||
|
$customField = CustomField::create();
|
||||||
|
$customField->hydrate($customFieldData);
|
||||||
|
$customField->save();
|
||||||
|
$association = SubscriberCustomField::create();
|
||||||
|
$association->subscriber_id = $this->subscriber->id;
|
||||||
|
$association->custom_field_id = $customField->id;
|
||||||
|
$association->save();
|
||||||
|
$subscriber = Subscriber::findOne($this->subscriber->id);
|
||||||
|
$subscriberCustomField = $subscriber->customFields()
|
||||||
|
->findOne();
|
||||||
|
expect($subscriberCustomField->id)->equals($customField->id);
|
||||||
|
}
|
||||||
|
|
||||||
function itCanCreateOrUpdate() {
|
function itCanCreateOrUpdate() {
|
||||||
$data = array(
|
$data = array(
|
||||||
'email' => 'john.doe@mailpoet.com',
|
'email' => 'john.doe@mailpoet.com',
|
||||||
'first_name' => 'John',
|
'first_name' => 'John',
|
||||||
'last_name' => 'Doe'
|
'last_name' => 'Doe'
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = Subscriber::createOrUpdate($data);
|
$result = Subscriber::createOrUpdate($data);
|
||||||
expect($result)->equals(true);
|
expect($result)->equals(true);
|
||||||
|
|
||||||
$record = Subscriber::where('email', $data['email'])
|
$record = Subscriber::where('email', $data['email'])
|
||||||
->findOne();
|
->findOne();
|
||||||
expect($record->first_name)->equals($data['first_name']);
|
expect($record->first_name)->equals($data['first_name']);
|
||||||
expect($record->last_name)->equals($data['last_name']);
|
expect($record->last_name)->equals($data['last_name']);
|
||||||
|
|
||||||
$record->last_name = 'Mailer';
|
$record->last_name = 'Mailer';
|
||||||
$result = Subscriber::createOrUpdate($record->asArray());
|
$result = Subscriber::createOrUpdate($record->asArray());
|
||||||
expect($result)->equals(true);
|
expect($result)->equals(true);
|
||||||
|
$record = Subscriber::where('email', $data['email'])
|
||||||
$record = Subscriber::where('email', $data['email'])->findOne();
|
->findOne();
|
||||||
expect($record->last_name)->equals('Mailer');
|
expect($record->last_name)->equals('Mailer');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,5 +164,9 @@ class SubscriberCest {
|
|||||||
->deleteMany();
|
->deleteMany();
|
||||||
ORM::forTable(SubscriberSegment::$_table)
|
ORM::forTable(SubscriberSegment::$_table)
|
||||||
->deleteMany();
|
->deleteMany();
|
||||||
|
ORM::forTable(CustomField::$_table)
|
||||||
|
->deleteMany();
|
||||||
|
ORM::forTable(SubscriberCustomField::$_table)
|
||||||
|
->deleteMany();
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user