Adds unit test for API entry point

This commit is contained in:
Vlad
2017-05-10 18:27:43 -04:00
parent 8b13889c7a
commit cedd94550f
2 changed files with 23 additions and 1 deletions

View File

@ -0,0 +1,22 @@
<?php
use MailPoet\API\API;
class APITest extends MailPoetTest {
function testItCallsJSONAPI() {
expect(API::JSON())->isInstanceOf('MailPoet\API\JSON\API');
}
function testItCallsMPAPI() {
expect(API::MP('v1'))->isInstanceOf('MailPoet\API\MP\v1\API');
}
function testItThrowsErrorWhenWrongMPAPIVersionIsCalled() {
try {
API::MP('invalid_version');
$this->fail('Incorrect API version exception should have been thrown.');
} catch(\Exception $e) {
expect($e->getMessage())->equals('Invalid API version.');
}
}
}

View File

@ -10,7 +10,7 @@ require_once(ABSPATH.'wp-admin/includes/user.php');
require_once('APITestNamespacedEndpointStubV1.php'); require_once('APITestNamespacedEndpointStubV1.php');
require_once('APITestNamespacedEndpointStubV2.php'); require_once('APITestNamespacedEndpointStubV2.php');
class APITest extends MailPoetTest { class JSONAPITest extends MailPoetTest {
function _before() { function _before() {
// create WP user // create WP user
$this->wp_user_id = null; $this->wp_user_id = null;