From cedd94550f30a1119f13db387583a53cba84b79f Mon Sep 17 00:00:00 2001 From: Vlad Date: Wed, 10 May 2017 18:27:43 -0400 Subject: [PATCH] Adds unit test for API entry point --- tests/unit/API/APITest.php | 22 ++++++++++++++++++++++ tests/unit/API/JSON/APITest.php | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/unit/API/APITest.php diff --git a/tests/unit/API/APITest.php b/tests/unit/API/APITest.php new file mode 100644 index 0000000000..6e42669359 --- /dev/null +++ b/tests/unit/API/APITest.php @@ -0,0 +1,22 @@ +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.'); + } + } +} \ No newline at end of file diff --git a/tests/unit/API/JSON/APITest.php b/tests/unit/API/JSON/APITest.php index f29a6eabe7..b0286501a1 100644 --- a/tests/unit/API/JSON/APITest.php +++ b/tests/unit/API/JSON/APITest.php @@ -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;