Mock is-WooCommerce-active detection in PostContentManagerTest
[MAILPOET-2382]
This commit is contained in:
committed by
Jack Kitterhing
parent
91cbe84bb9
commit
50043472ee
@@ -13,10 +13,10 @@ class PostContentManager {
|
|||||||
/** @var WooCommerceHelper */
|
/** @var WooCommerceHelper */
|
||||||
private $woocommerce_helper;
|
private $woocommerce_helper;
|
||||||
|
|
||||||
function __construct() {
|
function __construct(WooCommerceHelper $woocommerce_helper = null) {
|
||||||
$wp = new WPFunctions;
|
$wp = new WPFunctions;
|
||||||
$this->max_excerpt_length = $wp->applyFilters('mailpoet_newsletter_post_excerpt_length', $this->max_excerpt_length);
|
$this->max_excerpt_length = $wp->applyFilters('mailpoet_newsletter_post_excerpt_length', $this->max_excerpt_length);
|
||||||
$this->woocommerce_helper = new WooCommerceHelper();
|
$this->woocommerce_helper = $woocommerce_helper ?: new WooCommerceHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getContent($post, $displayType) {
|
function getContent($post, $displayType) {
|
||||||
|
@@ -3,13 +3,16 @@
|
|||||||
namespace MailPoet\Test\Newsletter\Editor;
|
namespace MailPoet\Test\Newsletter\Editor;
|
||||||
|
|
||||||
use MailPoet\Newsletter\Editor\PostContentManager;
|
use MailPoet\Newsletter\Editor\PostContentManager;
|
||||||
|
use MailPoet\WooCommerce\Helper as WooCommerceHelper;
|
||||||
use MailPoet\WP\Functions as WPFunctions;
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
|
|
||||||
class PostContentManagerTest extends \MailPoetTest {
|
class PostContentManagerTest extends \MailPoetTest {
|
||||||
|
|
||||||
function _before() {
|
function _before() {
|
||||||
parent::_before();
|
parent::_before();
|
||||||
$this->post_content = new PostContentManager();
|
$this->post_content = new PostContentManager(
|
||||||
|
$this->make(WooCommerceHelper::class, ['isWooCommerceActive' => false])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testFilterContentRetainsStructuralTags() {
|
function testFilterContentRetainsStructuralTags() {
|
||||||
@@ -133,7 +136,9 @@ class PostContentManagerTest extends \MailPoetTest {
|
|||||||
|
|
||||||
|
|
||||||
function testItAppliesCustomMaxExcerptLenghViaHook() {
|
function testItAppliesCustomMaxExcerptLenghViaHook() {
|
||||||
$post_content_manager = new PostContentManager();
|
$post_content_manager = new PostContentManager(
|
||||||
|
$this->make(WooCommerceHelper::class, ['isWooCommerceActive' => false])
|
||||||
|
);
|
||||||
$post = (object)[
|
$post = (object)[
|
||||||
'post_content' => '<p>one two three four five six</p>',
|
'post_content' => '<p>one two three four five six</p>',
|
||||||
];
|
];
|
||||||
@@ -145,7 +150,9 @@ class PostContentManagerTest extends \MailPoetTest {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
$post_content_manager = new PostContentManager();
|
$post_content_manager = new PostContentManager(
|
||||||
|
$this->make(WooCommerceHelper::class, ['isWooCommerceActive' => false])
|
||||||
|
);
|
||||||
$excerpt = $post_content_manager->getContent($post, 'excerpt');
|
$excerpt = $post_content_manager->getContent($post, 'excerpt');
|
||||||
expect($excerpt)->equals('one two …');
|
expect($excerpt)->equals('one two …');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user