From f4800dbbae3cdcb4ab763acaefa0e7be6d56d7df Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 24 Apr 2017 20:52:01 -0400 Subject: [PATCH] Removes namescape format enforcement --- lib/API/API.php | 5 ++--- tests/unit/API/APITest.php | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) 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']);