diff --git a/.phpstan/baseline.neon b/.phpstan/baseline.neon index b34c34e..de83541 100644 --- a/.phpstan/baseline.neon +++ b/.phpstan/baseline.neon @@ -1,10 +1,5 @@ parameters: ignoreErrors: - - - message: "#^Call to function is_string\\(\\) with stdClass will always evaluate to false\\.$#" - count: 2 - path: ../src/Bigcommerce/Api/Client.php - - message: "#^Method Bigcommerce\\\\Api\\\\Client\\:\\:createCoupon\\(\\) has parameter \\$object with no type specified\\.$#" count: 1 @@ -500,11 +495,6 @@ parameters: count: 1 path: ../src/Bigcommerce/Api/Filter.php - - - message: "#^Method Bigcommerce\\\\Api\\\\Filter\\:\\:__set\\(\\) has no return type specified\\.$#" - count: 1 - path: ../src/Bigcommerce/Api/Filter.php - - message: "#^Method Bigcommerce\\\\Api\\\\Filter\\:\\:__set\\(\\) has parameter \\$parameter with no type specified\\.$#" count: 1 diff --git a/composer.json b/composer.json index 09d90ff..6affced 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,6 @@ "ext-curl": "*" }, "require-dev": { - "codeless/jugglecode": "1.0", "friendsofphp/php-cs-fixer": "^3.13", "php-coveralls/php-coveralls": "2.5", "phpunit/phpunit": "^9.5", diff --git a/src/Bigcommerce/Api/Client.php b/src/Bigcommerce/Api/Client.php index 308c4cb..1cd61e9 100644 --- a/src/Bigcommerce/Api/Client.php +++ b/src/Bigcommerce/Api/Client.php @@ -115,6 +115,14 @@ public static function configureOAuth($settings) throw new Exception("'store_hash' must be provided"); } + if (isset($settings['api_url'])) { + self::$api_url = $settings['api_url']; + } + + if (isset($settings['login_url'])) { + self::$login_url = $settings['login_url']; + } + self::$client_id = $settings['client_id']; self::$auth_token = $settings['auth_token']; self::$store_hash = $settings['store_hash']; @@ -390,8 +398,8 @@ private static function mapCollectionObject($object) * Map a single object to a resource class. * * @param string $resource name of the resource class - * @param \stdClass $object - * @return Resource + * @param \stdClass|boolean|string $object + * @return bool|\stdClass|string */ private static function mapResource($resource, $object) { @@ -407,8 +415,8 @@ private static function mapResource($resource, $object) /** * Map object representing a count to an integer value. * - * @param \stdClass $object - * @return int + * @param \stdClass|boolean|string $object + * @return int|boolean */ private static function mapCount($object) { diff --git a/test/Unit/Api/ClientTest.php b/test/Unit/Api/ClientTest.php index b8e8db4..0a3890f 100644 --- a/test/Unit/Api/ClientTest.php +++ b/test/Unit/Api/ClientTest.php @@ -1084,4 +1084,22 @@ public function testUpdatingOptionValuePutsToTheOptionValueResource() Client::updateOptionValue(1, 1, array()); } + + public function testConnectionUsesApiUrlOverride() + { + $this->connection->expects($this->once()) + ->method('get') + ->with('https://api.url.com/time'); + + Client::configureOAuth([ + 'client_id' => '123', + 'auth_token' => '123xyz', + 'store_hash' => 'abc123', + 'api_url' => 'https://api.url.com', + 'login_url' => 'https://login.url.com', + ]); + Client::setConnection($this->connection); // re-set the connection since Client::setConnection unsets it + + Client::getTime(); + } }