Hide Automations menu for bundles
Using null instead of true so that the pages are available directly. [MAILPOET-5223]
This commit is contained in:
committed by
Aschepikov
parent
c5bc51fc86
commit
6b40dfabf3
@ -482,8 +482,14 @@ class Menu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function registerAutomationMenu(bool $showEntries) {
|
private function registerAutomationMenu(bool $showEntries) {
|
||||||
|
$parentSlug = self::MAIN_PAGE_SLUG;
|
||||||
|
// Automations menu is hidden when the subscription is part of a bundle and AutomateWoo is active but pages can be accessed directly
|
||||||
|
if ($this->wp->isPluginActive('automatewoo/automatewoo.php') && $this->servicesChecker->isBundledSubscription()) {
|
||||||
|
$parentSlug = null;
|
||||||
|
}
|
||||||
|
|
||||||
$automationPage = $this->wp->addSubmenuPage(
|
$automationPage = $this->wp->addSubmenuPage(
|
||||||
$showEntries ? self::MAIN_PAGE_SLUG : true,
|
$showEntries ? $parentSlug : true,
|
||||||
$this->setPageTitle(__('Automations', 'mailpoet')),
|
$this->setPageTitle(__('Automations', 'mailpoet')),
|
||||||
// @ToDo Remove Beta once Automation is no longer beta.
|
// @ToDo Remove Beta once Automation is no longer beta.
|
||||||
'<span>' . esc_html__('Automations', 'mailpoet') . '</span><span class="mailpoet-beta-badge">Beta</span>',
|
'<span>' . esc_html__('Automations', 'mailpoet') . '</span><span class="mailpoet-beta-badge">Beta</span>',
|
||||||
@ -503,6 +509,7 @@ class Menu {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Automation templates
|
// Automation templates
|
||||||
|
|
||||||
$this->wp->addSubmenuPage(
|
$this->wp->addSubmenuPage(
|
||||||
true,
|
true,
|
||||||
$this->setPageTitle(__('Automation Templates', 'mailpoet')),
|
$this->setPageTitle(__('Automation Templates', 'mailpoet')),
|
||||||
|
@ -3,8 +3,13 @@
|
|||||||
namespace MailPoet\Test\Config;
|
namespace MailPoet\Test\Config;
|
||||||
|
|
||||||
use Codeception\Util\Stub;
|
use Codeception\Util\Stub;
|
||||||
|
use MailPoet\Config\AccessControl;
|
||||||
|
use MailPoet\Config\Changelog;
|
||||||
use MailPoet\Config\Menu;
|
use MailPoet\Config\Menu;
|
||||||
|
use MailPoet\Config\Router;
|
||||||
use MailPoet\Config\ServicesChecker;
|
use MailPoet\Config\ServicesChecker;
|
||||||
|
use MailPoet\Form\Util\CustomFonts;
|
||||||
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
|
|
||||||
class MenuTest extends \MailPoetTest {
|
class MenuTest extends \MailPoetTest {
|
||||||
public function testItReturnsTrueIfCurrentPageBelongsToMailpoet() {
|
public function testItReturnsTrueIfCurrentPageBelongsToMailpoet() {
|
||||||
@ -56,4 +61,46 @@ class MenuTest extends \MailPoetTest {
|
|||||||
$menu->checkPremiumKey($checker);
|
$menu->checkPremiumKey($checker);
|
||||||
expect($menu->premiumKeyValid)->false();
|
expect($menu->premiumKeyValid)->false();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testItHidesAutomationIfBundledSubscriptionAndAutomateWooActive() {
|
||||||
|
$checker = Stub::make(
|
||||||
|
new ServicesChecker(),
|
||||||
|
[
|
||||||
|
'isPremiumKeyValid' => true,
|
||||||
|
'isBundledSubscription' => true,
|
||||||
|
],
|
||||||
|
$this
|
||||||
|
);
|
||||||
|
$changelog = $this->createMock(Changelog::class);
|
||||||
|
$changelog->method('shouldShowWelcomeWizard')->willReturn(false);
|
||||||
|
|
||||||
|
$wpMock = $this->createMock(WPFunctions::class);
|
||||||
|
$wpMock->method('isPluginActive')->willReturn(true);
|
||||||
|
$wpMock->method('addSubmenuPage')->willReturn(true);
|
||||||
|
|
||||||
|
$accessControlMock = $this->createMock(AccessControl::class);
|
||||||
|
$accessControlMock->method('validatePermission')->willReturn(true);
|
||||||
|
|
||||||
|
$wpMock->expects($this->at(8))->method('addSubmenuPage')->with(
|
||||||
|
null,
|
||||||
|
$this->anything(),
|
||||||
|
$this->anything(),
|
||||||
|
$this->anything(),
|
||||||
|
Menu::AUTOMATIONS_PAGE_SLUG,
|
||||||
|
$this->anything()
|
||||||
|
);
|
||||||
|
|
||||||
|
$menu = new Menu(
|
||||||
|
$accessControlMock,
|
||||||
|
$wpMock,
|
||||||
|
$checker,
|
||||||
|
$this->diContainer,
|
||||||
|
$this->diContainer->get(Router::class),
|
||||||
|
$this->diContainer->get(CustomFonts::class),
|
||||||
|
$changelog
|
||||||
|
);
|
||||||
|
|
||||||
|
$menu->setup();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user