diff --git a/lib/API/API.php b/lib/API/API.php index 8566436109..d03247684e 100644 --- a/lib/API/API.php +++ b/lib/API/API.php @@ -25,7 +25,7 @@ class API { function __construct() { foreach($this->_available_api_versions as $available_api_version) { $this->addEndpointNamespace( - sprintf('%s\%s', __NAMESPACE__, self::ENDPOINTS_LOCATION), + sprintf('%s\%s\%s', __NAMESPACE__, self::ENDPOINTS_LOCATION, $available_api_version), $available_api_version ); } @@ -89,9 +89,8 @@ class API { } else if(!empty($this->_endpoint_namespaces[$this->_request_api_version])) { foreach($this->_endpoint_namespaces[$this->_request_api_version] as $namespace) { $endpoint_class = sprintf( - '%s\%s\%s', + '%s\%s', $namespace, - $this->_request_api_version, ucfirst($this->_request_endpoint) ); if(class_exists($endpoint_class)) { diff --git a/tests/unit/API/APITest.php b/tests/unit/API/APITest.php index 9932feb6bb..81559d1956 100644 --- a/tests/unit/API/APITest.php +++ b/tests/unit/API/APITest.php @@ -84,7 +84,7 @@ class APITest extends MailPoetTest { function testItAcceptsAndProcessesAPIVersion() { $namespace = array( - 'name' => 'MailPoet\API\Endpoints', + 'name' => 'MailPoet\API\Endpoints\v2', 'version' => 'v2' ); $this->api->addEndpointNamespace($namespace['name'], $namespace['version']); @@ -104,7 +104,7 @@ class APITest extends MailPoetTest { function testItCallsAddedEndpoints() { $namespace = array( - 'name' => 'MailPoet\API\Endpoints', + 'name' => 'MailPoet\API\Endpoints\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\Endpoints', + 'name' => 'MailPoet\API\Endpoints\v2', 'version' => 'v2' ); $this->api->addEndpointNamespace($namespace['name'], $namespace['version']);