From 1201caba1e3cf400c6044dcadc539867ab31b28c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pysiak?= Date: Fri, 25 Oct 2024 07:04:37 +0200 Subject: [PATCH] Fix update password behat context --- src/Sylius/Behat/Client/ApiClientInterface.php | 2 ++ src/Sylius/Behat/Client/ApiPlatformClient.php | 7 ++++--- src/Sylius/Behat/Context/Api/Shop/CustomerContext.php | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Sylius/Behat/Client/ApiClientInterface.php b/src/Sylius/Behat/Client/ApiClientInterface.php index f1b02a1ccd1a..840e4ddf9e1c 100644 --- a/src/Sylius/Behat/Client/ApiClientInterface.php +++ b/src/Sylius/Behat/Client/ApiClientInterface.php @@ -57,6 +57,8 @@ public function buildCreateRequest(string $url): self; /** @param ?string $id Deprecated, pass the id as a part of the uri */ public function buildUpdateRequest(string $uri, ?string $id = null): self; + public function buildCustomUpdateRequest(string $uri, ?string $id = null): self; + /** @param array $data */ public function setRequestData(array $data): self; diff --git a/src/Sylius/Behat/Client/ApiPlatformClient.php b/src/Sylius/Behat/Client/ApiPlatformClient.php index 561393525d75..eef03f4182ee 100644 --- a/src/Sylius/Behat/Client/ApiPlatformClient.php +++ b/src/Sylius/Behat/Client/ApiPlatformClient.php @@ -188,15 +188,16 @@ public function buildUpdateRequest(string $uri, ?string $id = null): self return $this; } - public function buildCustomUpdateRequest(string $resource, string $id, string $customSuffix): void + public function buildCustomUpdateRequest(string $uri, ?string $id = null): self { $this->request = $this->requestFactory->update( $this->section, - $resource, - sprintf('%s/%s', $id, $customSuffix), + $uri, $this->authorizationHeader, $this->getToken(), ); + + return $this; } public function addParameter(string $key, bool|int|string $value): self diff --git a/src/Sylius/Behat/Context/Api/Shop/CustomerContext.php b/src/Sylius/Behat/Context/Api/Shop/CustomerContext.php index 03b89a0c793d..0b5901df275c 100644 --- a/src/Sylius/Behat/Context/Api/Shop/CustomerContext.php +++ b/src/Sylius/Behat/Context/Api/Shop/CustomerContext.php @@ -64,7 +64,7 @@ public function iWantToChangeMyPassword(): void /** @var CustomerInterface $customer */ $customer = $shopUser->getCustomer(); - $this->client->buildUpdateRequest(sprintf('customers/%s/password', $customer->getId())); + $this->client->buildCustomUpdateRequest(sprintf('customers/%s/password', $customer->getId())); } /**