Move WPHooks methods to WPFunctions
This commit is contained in:
@@ -7,7 +7,7 @@ use Codeception\Util\Stub;
|
||||
use Helper\WordPress as WPHelper;
|
||||
use Helper\WordPressHooks as WPHooksHelper;
|
||||
use MailPoet\Config\AccessControl;
|
||||
use MailPoet\WP\Hooks;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class AccessControlTest extends \MailPoetTest {
|
||||
function testItSetsDefaultPermissionsUponInitialization() {
|
||||
@@ -38,37 +38,38 @@ class AccessControlTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
function testItAllowsSettingCustomPermissions() {
|
||||
Hooks::addFilter(
|
||||
$wp = new WPFunctions;
|
||||
$wp->addFilter(
|
||||
'mailpoet_permission_access_plugin_admin',
|
||||
function() {
|
||||
return array('custom_access_plugin_admin_role');
|
||||
}
|
||||
);
|
||||
Hooks::addFilter(
|
||||
$wp->addFilter(
|
||||
'mailpoet_permission_manage_settings',
|
||||
function() {
|
||||
return array('custom_manage_settings_role');
|
||||
}
|
||||
);
|
||||
Hooks::addFilter(
|
||||
$wp->addFilter(
|
||||
'mailpoet_permission_manage_emails',
|
||||
function() {
|
||||
return array('custom_manage_emails_role');
|
||||
}
|
||||
);
|
||||
Hooks::addFilter(
|
||||
$wp->addFilter(
|
||||
'mailpoet_permission_manage_subscribers',
|
||||
function() {
|
||||
return array('custom_manage_subscribers_role');
|
||||
}
|
||||
);
|
||||
Hooks::addFilter(
|
||||
$wp->addFilter(
|
||||
'mailpoet_permission_manage_forms',
|
||||
function() {
|
||||
return array('custom_manage_forms_role');
|
||||
}
|
||||
);
|
||||
Hooks::addFilter(
|
||||
$wp->addFilter(
|
||||
'mailpoet_permission_manage_segments',
|
||||
function() {
|
||||
return array('custom_manage_segments_role');
|
||||
|
@@ -8,7 +8,7 @@ use Helper\WordPressHooks as WPHooksHelper;
|
||||
use MailPoet\Config\AccessControl;
|
||||
use MailPoet\Config\Capabilities;
|
||||
use MailPoet\Config\Renderer;
|
||||
use MailPoet\WP\Hooks;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class CapabilitiesTest extends \MailPoetTest {
|
||||
function _before() {
|
||||
@@ -60,7 +60,8 @@ class CapabilitiesTest extends \MailPoetTest {
|
||||
$filter = function() {
|
||||
return array('nonexistent_role');
|
||||
};
|
||||
Hooks::addFilter('mailpoet_permission_access_plugin_admin', $filter);
|
||||
$wp = new WPFunctions;
|
||||
$wp->addFilter('mailpoet_permission_access_plugin_admin', $filter);
|
||||
$this->caps->setupWPCapabilities();
|
||||
|
||||
// role does not exist
|
||||
@@ -72,7 +73,7 @@ class CapabilitiesTest extends \MailPoetTest {
|
||||
expect($editor_role->has_cap(AccessControl::PERMISSION_MANAGE_EMAILS))->true();
|
||||
|
||||
// Restore capabilities
|
||||
Hooks::removeFilter('mailpoet_permission_access_plugin_admin', $filter);
|
||||
$wp->removeFilter('mailpoet_permission_access_plugin_admin', $filter);
|
||||
$this->caps->setupWPCapabilities();
|
||||
|
||||
$editor_role = get_role('editor');
|
||||
@@ -81,7 +82,10 @@ class CapabilitiesTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
function testItSetsUpMembersCapabilities() {
|
||||
WPHooksHelper::interceptAddAction();
|
||||
$wp = Stub::make(new WPFunctions, [
|
||||
'addAction' => asCallable([WPHooksHelper::class, 'addAction'])
|
||||
]);
|
||||
$this->caps = new Capabilities(new Renderer, $wp);
|
||||
|
||||
$this->caps->setupMembersCapabilities();
|
||||
|
||||
@@ -113,7 +117,6 @@ class CapabilitiesTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
function _after() {
|
||||
WPHooksHelper::releaseAllHooks();
|
||||
Mock::clean();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user