Make key check method names consistent [PREMIUM-4]

This commit is contained in:
Alexey Stoletniy
2017-05-08 13:16:05 +03:00
parent f2bf61240a
commit 90b2b46db4
4 changed files with 17 additions and 17 deletions

View File

@ -19,7 +19,7 @@ class Services extends APIEndpoint {
$this->date_time = new DateTime();
}
function verifyMailPoetKey($data = array()) {
function checkMSSKey($data = array()) {
$key = isset($data['key']) ? trim($data['key']) : null;
if(!$key) {
@ -69,7 +69,7 @@ class Services extends APIEndpoint {
return $this->errorResponse(array(APIError::BAD_REQUEST => $error));
}
function verifyPremiumKey($data = array()) {
function checkPremiumKey($data = array()) {
$key = isset($data['key']) ? trim($data['key']) : null;
if(!$key) {

View File

@ -12,7 +12,7 @@ class ServicesTest extends MailPoetTest {
}
function testItRespondsWithErrorIfNoMSSKeyIsGiven() {
$response = $this->services_endpoint->verifyMailPoetKey(array('key' => ''));
$response = $this->services_endpoint->checkMSSKey(array('key' => ''));
expect($response->status)->equals(APIResponse::STATUS_BAD_REQUEST);
expect($response->errors[0]['message'])->equals('Please specify a key.');
}
@ -23,7 +23,7 @@ class ServicesTest extends MailPoetTest {
array('checkMSSKey' => array('state' => Bridge::MAILPOET_KEY_VALID)),
$this
);
$response = $this->services_endpoint->verifyMailPoetKey($this->data);
$response = $this->services_endpoint->checkMSSKey($this->data);
expect($response->status)->equals(APIResponse::STATUS_OK);
}
@ -33,7 +33,7 @@ class ServicesTest extends MailPoetTest {
array('checkMSSKey' => array('state' => Bridge::MAILPOET_KEY_INVALID)),
$this
);
$response = $this->services_endpoint->verifyMailPoetKey($this->data);
$response = $this->services_endpoint->checkMSSKey($this->data);
expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND);
}
@ -47,7 +47,7 @@ class ServicesTest extends MailPoetTest {
)),
$this
);
$response = $this->services_endpoint->verifyMailPoetKey($this->data);
$response = $this->services_endpoint->checkMSSKey($this->data);
expect($response->status)->equals(APIResponse::STATUS_OK);
expect($response->data['message'])
->contains($date->format($this->services_endpoint->date_time->getDateFormat()));
@ -59,7 +59,7 @@ class ServicesTest extends MailPoetTest {
array('checkMSSKey' => array('code' => Bridge::CHECK_ERROR_UNAVAILABLE)),
$this
);
$response = $this->services_endpoint->verifyMailPoetKey($this->data);
$response = $this->services_endpoint->checkMSSKey($this->data);
expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND);
expect($response->errors[0]['message'])->contains((string)Bridge::CHECK_ERROR_UNAVAILABLE);
}
@ -70,13 +70,13 @@ class ServicesTest extends MailPoetTest {
array('checkMSSKey' => function() { throw new \Exception('test'); }),
$this
);
$response = $this->services_endpoint->verifyMailPoetKey($this->data);
$response = $this->services_endpoint->checkMSSKey($this->data);
expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND);
expect($response->errors[0]['message'])->equals('test');
}
function testItRespondsWithErrorIfNoPremiumKeyIsGiven() {
$response = $this->services_endpoint->verifyPremiumKey(array('key' => ''));
$response = $this->services_endpoint->checkPremiumKey(array('key' => ''));
expect($response->status)->equals(APIResponse::STATUS_BAD_REQUEST);
expect($response->errors[0]['message'])->equals('Please specify a key.');
}
@ -87,7 +87,7 @@ class ServicesTest extends MailPoetTest {
array('checkPremiumKey' => array('state' => Bridge::PREMIUM_KEY_VALID)),
$this
);
$response = $this->services_endpoint->verifyPremiumKey($this->data);
$response = $this->services_endpoint->checkPremiumKey($this->data);
expect($response->status)->equals(APIResponse::STATUS_OK);
}
@ -97,7 +97,7 @@ class ServicesTest extends MailPoetTest {
array('checkPremiumKey' => array('state' => Bridge::PREMIUM_KEY_INVALID)),
$this
);
$response = $this->services_endpoint->verifyPremiumKey($this->data);
$response = $this->services_endpoint->checkPremiumKey($this->data);
expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND);
}
@ -107,7 +107,7 @@ class ServicesTest extends MailPoetTest {
array('checkPremiumKey' => array('state' => Bridge::PREMIUM_KEY_ALREADY_USED)),
$this
);
$response = $this->services_endpoint->verifyPremiumKey($this->data);
$response = $this->services_endpoint->checkPremiumKey($this->data);
expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND);
}
@ -121,7 +121,7 @@ class ServicesTest extends MailPoetTest {
)),
$this
);
$response = $this->services_endpoint->verifyPremiumKey($this->data);
$response = $this->services_endpoint->checkPremiumKey($this->data);
expect($response->status)->equals(APIResponse::STATUS_OK);
expect($response->data['message'])
->contains($date->format($this->services_endpoint->date_time->getDateFormat()));
@ -133,7 +133,7 @@ class ServicesTest extends MailPoetTest {
array('checkPremiumKey' => array('code' => Bridge::CHECK_ERROR_UNAVAILABLE)),
$this
);
$response = $this->services_endpoint->verifyPremiumKey($this->data);
$response = $this->services_endpoint->checkPremiumKey($this->data);
expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND);
expect($response->errors[0]['message'])->contains((string)Bridge::CHECK_ERROR_UNAVAILABLE);
}
@ -144,7 +144,7 @@ class ServicesTest extends MailPoetTest {
array('checkPremiumKey' => function() { throw new \Exception('test'); }),
$this
);
$response = $this->services_endpoint->verifyPremiumKey($this->data);
$response = $this->services_endpoint->checkPremiumKey($this->data);
expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND);
expect($response->errors[0]['message'])->equals('test');
}

View File

@ -754,7 +754,7 @@
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'services',
action: 'verifyMailPoetKey',
action: 'checkMSSKey',
data: {
key: key
}

View File

@ -86,7 +86,7 @@
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'services',
action: 'verifyPremiumKey',
action: 'checkPremiumKey',
data: {
key: key
}