Add unit tests [MAILPOET-743]

This commit is contained in:
Alexey Stoletniy
2017-01-16 20:09:17 +03:00
parent 1f91d40def
commit 438b4fb1ec
15 changed files with 596 additions and 34 deletions

View File

@@ -27,12 +27,7 @@ class Menu {
$this->assets_url = $assets_url;
$subscribers_feature = new SubscribersFeature();
$this->subscribers_over_limit = $subscribers_feature->check();
if(self::isOnMailPoetAdminPage()) {
$show_notices = isset($_REQUEST['page'])
&& stripos($_REQUEST['page'], 'mailpoet-newsletters') === false;
$checker = new ServicesChecker();
$this->mp_api_key_valid = $checker->checkMailPoetAPIKeyValid($show_notices);
}
$this->checkMailPoetAPIKey();
}
function init() {
@@ -516,6 +511,15 @@ class Menu {
return (stripos($screen_id, 'mailpoet-') !== false);
}
function checkMailPoetAPIKey(ServicesChecker $checker = null) {
if(self::isOnMailPoetAdminPage()) {
$show_notices = isset($_REQUEST['page'])
&& stripos($_REQUEST['page'], 'mailpoet-newsletters') === false;
$checker = $checker ?: new ServicesChecker();
$this->mp_api_key_valid = $checker->checkMailPoetAPIKeyValid($show_notices);
}
}
private function getLimitPerPage($model = null) {
if($model === null) {
return Listing\Handler::DEFAULT_LIMIT_PER_PAGE;