From ab3b35b4cbbb3f43bf532236ebff7384227c7fd7 Mon Sep 17 00:00:00 2001 From: tleon Date: Thu, 28 Mar 2024 16:29:31 +0100 Subject: [PATCH] chore(api) modify customer group endpoint mapping and tests --- src/ApiPlatform/Resources/CustomerGroup.php | 2 +- .../ApiPlatform/CustomerGroupApiTest.php | 41 ++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/ApiPlatform/Resources/CustomerGroup.php b/src/ApiPlatform/Resources/CustomerGroup.php index 77ed229..1b34a46 100644 --- a/src/ApiPlatform/Resources/CustomerGroup.php +++ b/src/ApiPlatform/Resources/CustomerGroup.php @@ -1,5 +1,4 @@ '[shopIds]', '[groupId]' => '[customerGroupId]', ], ), diff --git a/tests/Integration/ApiPlatform/CustomerGroupApiTest.php b/tests/Integration/ApiPlatform/CustomerGroupApiTest.php index 4c2d7ef..938789e 100644 --- a/tests/Integration/ApiPlatform/CustomerGroupApiTest.php +++ b/tests/Integration/ApiPlatform/CustomerGroupApiTest.php @@ -1,5 +1,4 @@ language->id)); + + $bearerToken = $this->getBearerToken(['customer_group_write']); + $response = static::createClient()->request('POST', '/customers/group', [ + 'auth_bearer' => $bearerToken, + 'json' => [ + 'localizedNames' => [ + 1 => 'test1', + ], + 'reductionPercent' => 10.3, + 'displayPriceTaxExcluded' => true, + 'showPrice' => true, + ], + ]); + self::assertResponseStatusCodeSame(201); + self::assertCount($numberOfGroups + 1, \Group::getGroups(\Context::getContext()->language->id)); + + $decodedResponse = json_decode($response->getContent(), true); + $this->assertNotFalse($decodedResponse); + $this->assertArrayHasKey('customerGroupId', $decodedResponse); + $customerGroupId = $decodedResponse['customerGroupId']; + $this->assertEquals( + [ + 'customerGroupId' => $customerGroupId, + 'localizedNames' => [ + 1 => 'test1', + ], + 'reductionPercent' => 10.3, + 'displayPriceTaxExcluded' => true, + 'showPrice' => true, + 'shopIds' => [1], + ], + $decodedResponse + ); + + return $customerGroupId; + } + /** * @depends testAddCustomerGroup *