Refactor AccessControl static methods to instance methods
[MAIPOET-1823]
This commit is contained in:
committed by
M. Shull
parent
171b3564f9
commit
1179747324
@@ -12,6 +12,7 @@ use MailPoet\Models\Subscriber;
|
||||
use MailPoet\Router\Endpoints\ViewInBrowser;
|
||||
use MailPoet\Settings\SettingsController;
|
||||
use MailPoet\Tasks\Sending as SendingTask;
|
||||
use MailPoet\WP\Functions;
|
||||
|
||||
class ViewInBrowserTest extends \MailPoetTest {
|
||||
function _before() {
|
||||
@@ -41,7 +42,7 @@ class ViewInBrowserTest extends \MailPoetTest {
|
||||
'preview' => false
|
||||
);
|
||||
// instantiate class
|
||||
$this->view_in_browser = new ViewInBrowser(new AccessControl(), new SettingsController());
|
||||
$this->view_in_browser = new ViewInBrowser(new AccessControl(new Functions()), new SettingsController());
|
||||
}
|
||||
|
||||
function testItAbortsWhenBrowserPreviewDataIsMissing() {
|
||||
@@ -149,12 +150,12 @@ class ViewInBrowserTest extends \MailPoetTest {
|
||||
$wp_user = wp_set_current_user(0);
|
||||
// when WP user does not have 'manage options' permission, false should be returned
|
||||
$wp_user->remove_role('administrator');
|
||||
$view_in_browser = new ViewInBrowser(new AccessControl(), new SettingsController());
|
||||
$view_in_browser = new ViewInBrowser(new AccessControl(new Functions()), new SettingsController());
|
||||
expect($view_in_browser->_validateBrowserPreviewData($data))->false();
|
||||
|
||||
// when WP has 'manage options' permission, data should be returned
|
||||
$wp_user->add_role('administrator');
|
||||
$view_in_browser = new ViewInBrowser(new AccessControl(), new SettingsController());
|
||||
$view_in_browser = new ViewInBrowser(new AccessControl(new Functions()), new SettingsController());
|
||||
expect($view_in_browser->_validateBrowserPreviewData($data))->equals($data);
|
||||
}
|
||||
|
||||
@@ -170,7 +171,7 @@ class ViewInBrowserTest extends \MailPoetTest {
|
||||
);
|
||||
$data->preview = true;
|
||||
wp_set_current_user(1);
|
||||
$view_in_browser = new ViewInBrowser(new AccessControl(), new SettingsController());
|
||||
$view_in_browser = new ViewInBrowser(new AccessControl(new Functions()), new SettingsController());
|
||||
$result = $view_in_browser->_validateBrowserPreviewData($data);
|
||||
expect($result->subscriber->id)->equals(1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user