From eb01ef2f58cdbb9763ad3062de4f9cc369568cec Mon Sep 17 00:00:00 2001 From: Jens Schulze Date: Tue, 21 Jan 2025 22:08:40 +0100 Subject: [PATCH 1/2] fix Credentials deprecation --- .github/workflows/ci.yml | 3 +++ lib/commercetools-base/src/Client/ClientCredentials.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f3a2759848b..1c9878cce01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,6 +98,9 @@ jobs: - "7.4" - "8.0" - "8.1" + - "8.2" + - "8.3" + - "8.4" dependencies: - lowest - highest diff --git a/lib/commercetools-base/src/Client/ClientCredentials.php b/lib/commercetools-base/src/Client/ClientCredentials.php index 9592609df30..8525d34e6d1 100644 --- a/lib/commercetools-base/src/Client/ClientCredentials.php +++ b/lib/commercetools-base/src/Client/ClientCredentials.php @@ -38,12 +38,12 @@ class ClientCredentials * Format: `:`. * Example: `manage_products:project1`. */ - public function __construct(string $clientId, string $clientSecret, string $scope = null) + public function __construct(string $clientId, string $clientSecret, ?string $scope) { $this->clientId = $clientId; $this->clientSecret = $clientSecret; $this->scope = $scope; - $this->cacheKey = sha1($clientId . (string)$scope); + $this->cacheKey = sha1($clientId . $scope); } public function getClientId(): string From 8d312913494b337d2fc7eaefc63bc924760157b3 Mon Sep 17 00:00:00 2001 From: Jens Schulze Date: Tue, 21 Jan 2025 22:15:42 +0100 Subject: [PATCH 2/2] test: clientcredentials instance --- lib/commercetools-base/src/Client/ClientCredentials.php | 4 ++-- test/unit/MiscTest.php | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/commercetools-base/src/Client/ClientCredentials.php b/lib/commercetools-base/src/Client/ClientCredentials.php index 8525d34e6d1..ce310a7db4d 100644 --- a/lib/commercetools-base/src/Client/ClientCredentials.php +++ b/lib/commercetools-base/src/Client/ClientCredentials.php @@ -32,13 +32,13 @@ class ClientCredentials * The client id. * @param string $clientSecret * The client secret. - * @param string $scope + * @param ?string $scope * Provide the scope when you want to request a specific ones for the client. * Can be omitted to use all scopes of the oauth client. * Format: `:`. * Example: `manage_products:project1`. */ - public function __construct(string $clientId, string $clientSecret, ?string $scope) + public function __construct(string $clientId, string $clientSecret, ?string $scope = null) { $this->clientId = $clientId; $this->clientSecret = $clientSecret; diff --git a/test/unit/MiscTest.php b/test/unit/MiscTest.php index a7f616f51af..ba787cafbb1 100644 --- a/test/unit/MiscTest.php +++ b/test/unit/MiscTest.php @@ -37,6 +37,7 @@ use Commercetools\Api\Models\Type\TypeReferenceBuilder; use Commercetools\Api\Models\Type\TypeResourceIdentifierBuilder; use Commercetools\Base\JsonObject; +use Commercetools\Client\ClientCredentials; use Commercetools\Client\ClientFactory; use GuzzleHttp\Psr7\Response; use PHPUnit\Framework\TestCase; @@ -289,4 +290,11 @@ public function testAddressDraft() json_encode($cart) ); } + + + public function testCredentials() + { + $credentials = new ClientCredentials("clientId", "clientSecret"); + $this->assertInstanceOf(ClientCredentials::class, $credentials); + } }