Adds unit test for API entry point
This commit is contained in:
22
tests/unit/API/APITest.php
Normal file
22
tests/unit/API/APITest.php
Normal 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.');
|
||||
}
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ require_once(ABSPATH.'wp-admin/includes/user.php');
|
||||
require_once('APITestNamespacedEndpointStubV1.php');
|
||||
require_once('APITestNamespacedEndpointStubV2.php');
|
||||
|
||||
class APITest extends MailPoetTest {
|
||||
class JSONAPITest extends MailPoetTest {
|
||||
function _before() {
|
||||
// create WP user
|
||||
$this->wp_user_id = null;
|
||||
|
Reference in New Issue
Block a user