add tests

This commit is contained in:
qfrery
2018-07-15 22:19:51 +01:00
parent 2851fa3a4a
commit 0d461c2e30
2 changed files with 48 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ use Codeception\Stub\Expected;
use MailPoet\API\JSON\v1\Services;
use MailPoet\API\JSON\Response as APIResponse;
use MailPoet\Config\Installer;
use MailPoet\Models\Setting;
use MailPoet\Services\Bridge;
class ServicesTest extends \MailPoetTest {
@@ -263,4 +264,32 @@ class ServicesTest extends \MailPoetTest {
expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND);
expect($response->errors[0]['message'])->equals('test');
}
function testItRespondsContainsPublicIdForMSS() {
$this->services_endpoint->bridge = Stub::make(
new Bridge(),
array(
'checkMSSKey' => array('state' => Bridge::KEY_VALID),
'storeMSSKeyAndState' => Expected::once()
),
$this
);
$response = $this->services_endpoint->checkMSSKey($this->data);
expect($response->data['public_id'])->notEmpty();
expect($response->data['public_id'])->equals(Setting::getValue('public_id'););
}
function testItRespondsContainsPublicIdForPremium() {
$this->services_endpoint->bridge = Stub::make(
new Bridge(),
array(
'checkPremiumKey' => array('state' => Bridge::KEY_VALID),
'storeMSSKeyAndState' => Expected::once()
),
$this
);
$response = $this->services_endpoint->checkMSSKey($this->data);
expect($response->data['public_id'])->notEmpty();
expect($response->data['public_id'])->equals(Setting::getValue('public_id'););
}
}