fix tests
This commit is contained in:
@ -13,6 +13,8 @@ $models = array(
|
|||||||
'Newsletter',
|
'Newsletter',
|
||||||
'NewsletterSegment',
|
'NewsletterSegment',
|
||||||
'NewsletterTemplate',
|
'NewsletterTemplate',
|
||||||
|
'NewsletterOption',
|
||||||
|
'NewsletterOptionField',
|
||||||
'Segment',
|
'Segment',
|
||||||
'SendingQueue',
|
'SendingQueue',
|
||||||
'Setting',
|
'Setting',
|
||||||
|
@ -3,16 +3,19 @@
|
|||||||
use MailPoet\Models\Newsletter;
|
use MailPoet\Models\Newsletter;
|
||||||
use MailPoet\Models\NewsletterOption;
|
use MailPoet\Models\NewsletterOption;
|
||||||
use MailPoet\Models\NewsletterOptionField;
|
use MailPoet\Models\NewsletterOptionField;
|
||||||
|
use MailPoet\Config\Populator;
|
||||||
|
|
||||||
class NewsletterOptionFieldTest extends MailPoetTest {
|
class NewsletterOptionFieldTest extends MailPoetTest {
|
||||||
function _before() {
|
function _before() {
|
||||||
$this->data = array(
|
$this->data = array(
|
||||||
'name' => 'Event',
|
'name' => 'event',
|
||||||
'newsletter_type' => 'welcome'
|
'newsletter_type' => 'welcome'
|
||||||
);
|
);
|
||||||
$option = NewsletterOptionField::create();
|
$option = NewsletterOptionField::create();
|
||||||
$option->hydrate($this->data);
|
$option->hydrate($this->data);
|
||||||
$this->option_field = $option->save();
|
$option->save();
|
||||||
|
|
||||||
|
$this->option_field = NewsletterOptionField::findOne($option->id);
|
||||||
|
|
||||||
$this->newsletter_data = array(
|
$this->newsletter_data = array(
|
||||||
array(
|
array(
|
||||||
@ -31,7 +34,7 @@ class NewsletterOptionFieldTest extends MailPoetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testItCanBeCreated() {
|
function testItCanBeCreated() {
|
||||||
expect($this->option_field->id() > 0)->true();
|
expect($this->option_field->id() > 0)->equals(true);
|
||||||
expect($this->option_field->getErrors())->false();
|
expect($this->option_field->getErrors())->false();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,9 +58,8 @@ class NewsletterOptionFieldTest extends MailPoetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testItHasACreatedAtOnCreation() {
|
function testItHasACreatedAtOnCreation() {
|
||||||
$option_field = NewsletterOptionField::findOne($this->option_field->id);
|
expect($this->option_field->created_at)->notNull();
|
||||||
expect($option_field->created_at)->notNull();
|
expect($this->option_field->created_at)->notEquals('0000-00-00 00:00:00');
|
||||||
expect($option_field->created_at)->notEquals('0000-00-00 00:00:00');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function testItHasAnUpdatedAtOnCreation() {
|
function testItHasAnUpdatedAtOnCreation() {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
|
||||||
use MailPoet\Models\Subscriber;
|
use MailPoet\Models\Subscriber;
|
||||||
|
use MailPoet\Config\Populator;
|
||||||
|
use MailPoet\Subscription\Url as SubscriptionUrl;
|
||||||
|
|
||||||
class ShortcodesTest extends MailPoetTest {
|
class ShortcodesTest extends MailPoetTest {
|
||||||
public $rendered_newsletter;
|
public $rendered_newsletter;
|
||||||
@ -8,6 +10,8 @@ class ShortcodesTest extends MailPoetTest {
|
|||||||
public $subscriber;
|
public $subscriber;
|
||||||
|
|
||||||
function _before() {
|
function _before() {
|
||||||
|
$populator = new Populator();
|
||||||
|
$populator->up();
|
||||||
$this->wp_user = $this->_createWPUser();
|
$this->wp_user = $this->_createWPUser();
|
||||||
$this->subscriber = $this->_createSubscriber();
|
$this->subscriber = $this->_createSubscriber();
|
||||||
$this->newsletter['subject'] = 'some subject';
|
$this->newsletter['subject'] = 'some subject';
|
||||||
@ -30,9 +34,9 @@ class ShortcodesTest extends MailPoetTest {
|
|||||||
Month text: [date:mtext].
|
Month text: [date:mtext].
|
||||||
Year: [date:y]
|
Year: [date:y]
|
||||||
|
|
||||||
You can unsubscribe here: [global:unsubscribe].
|
You can unsubscribe here: [subscription:unsubscribe_url].
|
||||||
Manage your subscription here: [global:manage].
|
Manage your subscription here: [subscription:manage_url].
|
||||||
View this newsletter in browser: [global:browser].';
|
View this newsletter in browser: [newsletter:view_in_browser_url].';
|
||||||
$this->shortcodes_object = new MailPoet\Newsletter\Shortcodes\Shortcodes(
|
$this->shortcodes_object = new MailPoet\Newsletter\Shortcodes\Shortcodes(
|
||||||
$this->rendered_newsletter,
|
$this->rendered_newsletter,
|
||||||
$this->newsletter,
|
$this->newsletter,
|
||||||
@ -52,6 +56,11 @@ class ShortcodesTest extends MailPoetTest {
|
|||||||
$date = new \DateTime('now');
|
$date = new \DateTime('now');
|
||||||
$subscriber_count = Subscriber::count();
|
$subscriber_count = Subscriber::count();
|
||||||
$newsletter_with_replaced_shortcodes = $this->shortcodes_object->replace();
|
$newsletter_with_replaced_shortcodes = $this->shortcodes_object->replace();
|
||||||
|
|
||||||
|
$unsubscribe_url = SubscriptionUrl::getUnsubscribeUrl($this->subscriber);
|
||||||
|
$manage_url = SubscriptionUrl::getManageUrl($this->subscriber);
|
||||||
|
$view_in_browser_url = '#TODO';
|
||||||
|
|
||||||
expect($newsletter_with_replaced_shortcodes)->equals("
|
expect($newsletter_with_replaced_shortcodes)->equals("
|
||||||
Hello {$wp_user->user_login}.
|
Hello {$wp_user->user_login}.
|
||||||
Your first name is {$this->subscriber->first_name}.
|
Your first name is {$this->subscriber->first_name}.
|
||||||
@ -62,7 +71,7 @@ class ShortcodesTest extends MailPoetTest {
|
|||||||
There are {$wp_post_count->publish} posts on this blog.
|
There are {$wp_post_count->publish} posts on this blog.
|
||||||
You are reading {$this->newsletter['subject']}.
|
You are reading {$this->newsletter['subject']}.
|
||||||
The latest post on this blog is called {$wp_latest_post}.
|
The latest post on this blog is called {$wp_latest_post}.
|
||||||
The issue number of this newsletter is [newsletter:number].
|
The issue number of this newsletter is 1.
|
||||||
|
|
||||||
Date: {$date->format('d')}.
|
Date: {$date->format('d')}.
|
||||||
Ordinal date: {$date->format('dS')}.
|
Ordinal date: {$date->format('dS')}.
|
||||||
@ -71,9 +80,9 @@ class ShortcodesTest extends MailPoetTest {
|
|||||||
Month text: {$date->format('F')}.
|
Month text: {$date->format('F')}.
|
||||||
Year: {$date->format('Y')}
|
Year: {$date->format('Y')}
|
||||||
|
|
||||||
You can unsubscribe here: [global:unsubscribe].
|
You can unsubscribe here: {$unsubscribe_url}.
|
||||||
Manage your subscription here: [global:manage].
|
Manage your subscription here: {$manage_url}.
|
||||||
View this newsletter in browser: [global:browser].");
|
View this newsletter in browser: {$view_in_browser_url}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
function _createWPUser() {
|
function _createWPUser() {
|
||||||
@ -103,4 +112,4 @@ class ShortcodesTest extends MailPoetTest {
|
|||||||
function _after() {
|
function _after() {
|
||||||
Subscriber::deleteMany();
|
Subscriber::deleteMany();
|
||||||
}
|
}
|
||||||
}*/
|
}
|
Reference in New Issue
Block a user