- Adds unit test for shortcodes helper class
This commit is contained in:
38
tests/unit/Newsletter/ShortcodesHelperTest.php
Normal file
38
tests/unit/Newsletter/ShortcodesHelperTest.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use MailPoet\Models\CustomField;
|
||||
use MailPoet\Newsletter\Shortcodes\ShortcodesHelper;
|
||||
|
||||
class ShortcodesHelperTest extends MailPoetTest {
|
||||
function testItCanGetShortcodes() {
|
||||
$shortcodes = ShortcodesHelper::getShortcodes();
|
||||
expect(array_keys($shortcodes))->equals(
|
||||
array(
|
||||
'Subscriber',
|
||||
'Newsletter',
|
||||
'Post Notifications',
|
||||
'Date',
|
||||
'Links'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function testItCanGetCustomShortShortcodes() {
|
||||
$shortcodes = ShortcodesHelper::getShortcodes();
|
||||
expect(count($shortcodes['Subscriber']))->equals(5);
|
||||
$custom_field = CustomField::create();
|
||||
$custom_field->name = 'name';
|
||||
$custom_field->type = 'type';
|
||||
$custom_field->save();
|
||||
$shortcodes = ShortcodesHelper::getShortcodes();
|
||||
expect(count($shortcodes['Subscriber']))->equals(6);
|
||||
$custom_subscriber_shortcode = end($shortcodes['Subscriber']);
|
||||
expect($custom_subscriber_shortcode['text'])->equals($custom_field->name);
|
||||
expect($custom_subscriber_shortcode['shortcode'])
|
||||
->equals('subscriber:cf_' . $custom_field->id);
|
||||
}
|
||||
|
||||
function _after() {
|
||||
ORM::raw_execute('TRUNCATE ' . CustomField::$_table);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user