diff --git a/lib/API/API.php b/lib/API/API.php new file mode 100644 index 0000000000..3c13d8e2f0 --- /dev/null +++ b/lib/API/API.php @@ -0,0 +1,18 @@ +_available_api_versions as $available_api_version) { $this->addEndpointNamespace( - sprintf('%s\%s\%s', __NAMESPACE__, self::ENDPOINTS_LOCATION, $available_api_version), + sprintf('%s\%s', __NAMESPACE__, $available_api_version), $available_api_version ); } diff --git a/lib/API/JSON/Endpoints/v1/AutomatedLatestContent.php b/lib/API/JSON/v1/AutomatedLatestContent.php similarity index 97% rename from lib/API/JSON/Endpoints/v1/AutomatedLatestContent.php rename to lib/API/JSON/v1/AutomatedLatestContent.php index 3c6c7fd145..74d0ac4a29 100644 --- a/lib/API/JSON/Endpoints/v1/AutomatedLatestContent.php +++ b/lib/API/JSON/v1/AutomatedLatestContent.php @@ -1,5 +1,5 @@ init(); + API\API::JSON()->init(); } function setupRouter() { diff --git a/tests/unit/API/JSON/APITest.php b/tests/unit/API/JSON/APITest.php index a27365eac0..f29a6eabe7 100644 --- a/tests/unit/API/JSON/APITest.php +++ b/tests/unit/API/JSON/APITest.php @@ -84,7 +84,7 @@ class APITest extends MailPoetTest { function testItAcceptsAndProcessesAPIVersion() { $namespace = array( - 'name' => 'MailPoet\API\JSON\Endpoints\v2', + 'name' => 'MailPoet\API\JSON\v2', 'version' => 'v2' ); $this->api->addEndpointNamespace($namespace['name'], $namespace['version']); @@ -98,13 +98,13 @@ class APITest extends MailPoetTest { expect($this->api->getRequestedAPIVersion())->equals('v2'); expect($this->api->getRequestedEndpointClass())->equals( - 'MailPoet\API\JSON\Endpoints\v2\NamespacedEndpointStub' + 'MailPoet\API\JSON\v2\NamespacedEndpointStub' ); } function testItCallsAddedEndpoints() { $namespace = array( - 'name' => 'MailPoet\API\JSON\Endpoints\v1', + 'name' => 'MailPoet\API\JSON\v1', 'version' => 'v1' ); $this->api->addEndpointNamespace($namespace['name'], $namespace['version']); @@ -123,7 +123,7 @@ class APITest extends MailPoetTest { function testItCallsAddedEndpointsForSpecificAPIVersion() { $namespace = array( - 'name' => 'MailPoet\API\JSON\Endpoints\v2', + 'name' => 'MailPoet\API\JSON\v2', 'version' => 'v2' ); $this->api->addEndpointNamespace($namespace['name'], $namespace['version']); diff --git a/tests/unit/API/JSON/APITestNamespacedEndpointStubV1.php b/tests/unit/API/JSON/APITestNamespacedEndpointStubV1.php index 148942e348..e261461208 100644 --- a/tests/unit/API/JSON/APITestNamespacedEndpointStubV1.php +++ b/tests/unit/API/JSON/APITestNamespacedEndpointStubV1.php @@ -1,6 +1,6 @@