diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php index b83c80f8cd..005c48b735 100644 --- a/tests/_bootstrap.php +++ b/tests/_bootstrap.php @@ -13,6 +13,8 @@ $models = array( 'Newsletter', 'NewsletterSegment', 'NewsletterTemplate', + 'NewsletterOption', + 'NewsletterOptionField', 'Segment', 'SendingQueue', 'Setting', diff --git a/tests/unit/Models/NewsletterOptionFieldTest.php b/tests/unit/Models/NewsletterOptionFieldTest.php index 64cafe618f..b57a280387 100644 --- a/tests/unit/Models/NewsletterOptionFieldTest.php +++ b/tests/unit/Models/NewsletterOptionFieldTest.php @@ -3,16 +3,19 @@ use MailPoet\Models\Newsletter; use MailPoet\Models\NewsletterOption; use MailPoet\Models\NewsletterOptionField; +use MailPoet\Config\Populator; class NewsletterOptionFieldTest extends MailPoetTest { function _before() { $this->data = array( - 'name' => 'Event', + 'name' => 'event', 'newsletter_type' => 'welcome' ); $option = NewsletterOptionField::create(); $option->hydrate($this->data); - $this->option_field = $option->save(); + $option->save(); + + $this->option_field = NewsletterOptionField::findOne($option->id); $this->newsletter_data = array( array( @@ -31,7 +34,7 @@ class NewsletterOptionFieldTest extends MailPoetTest { } function testItCanBeCreated() { - expect($this->option_field->id() > 0)->true(); + expect($this->option_field->id() > 0)->equals(true); expect($this->option_field->getErrors())->false(); } @@ -55,9 +58,8 @@ class NewsletterOptionFieldTest extends MailPoetTest { } function testItHasACreatedAtOnCreation() { - $option_field = NewsletterOptionField::findOne($this->option_field->id); - expect($option_field->created_at)->notNull(); - expect($option_field->created_at)->notEquals('0000-00-00 00:00:00'); + expect($this->option_field->created_at)->notNull(); + expect($this->option_field->created_at)->notEquals('0000-00-00 00:00:00'); } function testItHasAnUpdatedAtOnCreation() { diff --git a/tests/unit/Newsletter/ShortcodesTest.php b/tests/unit/Newsletter/ShortcodesTest.php index b7805626a3..5315f59ebc 100644 --- a/tests/unit/Newsletter/ShortcodesTest.php +++ b/tests/unit/Newsletter/ShortcodesTest.php @@ -1,6 +1,8 @@ up(); $this->wp_user = $this->_createWPUser(); $this->subscriber = $this->_createSubscriber(); $this->newsletter['subject'] = 'some subject'; @@ -30,9 +34,9 @@ class ShortcodesTest extends MailPoetTest { Month text: [date:mtext]. Year: [date:y] - You can unsubscribe here: [global:unsubscribe]. - Manage your subscription here: [global:manage]. - View this newsletter in browser: [global:browser].'; + You can unsubscribe here: [subscription:unsubscribe_url]. + Manage your subscription here: [subscription:manage_url]. + View this newsletter in browser: [newsletter:view_in_browser_url].'; $this->shortcodes_object = new MailPoet\Newsletter\Shortcodes\Shortcodes( $this->rendered_newsletter, $this->newsletter, @@ -52,6 +56,11 @@ class ShortcodesTest extends MailPoetTest { $date = new \DateTime('now'); $subscriber_count = Subscriber::count(); $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(" Hello {$wp_user->user_login}. 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. You are reading {$this->newsletter['subject']}. 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')}. Ordinal date: {$date->format('dS')}. @@ -71,9 +80,9 @@ class ShortcodesTest extends MailPoetTest { Month text: {$date->format('F')}. Year: {$date->format('Y')} - You can unsubscribe here: [global:unsubscribe]. - Manage your subscription here: [global:manage]. - View this newsletter in browser: [global:browser]."); + You can unsubscribe here: {$unsubscribe_url}. + Manage your subscription here: {$manage_url}. + View this newsletter in browser: {$view_in_browser_url}."); } function _createWPUser() { @@ -103,4 +112,4 @@ class ShortcodesTest extends MailPoetTest { function _after() { Subscriber::deleteMany(); } -}*/ \ No newline at end of file +} \ No newline at end of file