diff --git a/disabledTests/Api/Admin/PromotionsTest.php b/disabledTests/Api/Admin/PromotionsTest.php index 303341e581..3753f3d050 100644 --- a/disabledTests/Api/Admin/PromotionsTest.php +++ b/disabledTests/Api/Admin/PromotionsTest.php @@ -35,28 +35,6 @@ final class PromotionsTest extends JsonApiTestCase { use AdminUserLoginTrait; - /** @test */ - public function it_gets_a_promotion(): void - { - $fixtures = $this->loadFixturesFromFiles(['authentication/api_administrator.yaml', 'channel.yaml', 'promotion/promotion.yaml']); - $header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER); - - /** @var PromotionInterface $promotion */ - $promotion = $fixtures['promotion_50_off']; - - $this->client->request( - method: 'GET', - uri: sprintf('/api/v2/admin/promotions/%s', $promotion->getCode()), - server: $header, - ); - - $this->assertResponse( - $this->client->getResponse(), - 'admin/promotion/get_promotion_response', - Response::HTTP_OK, - ); - } - /** @test */ public function it_gets_promotions(): void { @@ -625,44 +603,4 @@ final class PromotionsTest extends JsonApiTestCase Response::HTTP_OK, ); } - - /** @test */ - public function it_deletes_a_promotion(): void - { - $fixtures = $this->loadFixturesFromFiles(['authentication/api_administrator.yaml', 'channel.yaml', 'promotion/promotion.yaml']); - $header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER); - - /** @var PromotionInterface $promotion */ - $promotion = $fixtures['promotion_50_off']; - - $this->client->request( - method: 'DELETE', - uri: sprintf('/api/v2/admin/promotions/%s', $promotion->getCode()), - server: $header, - ); - - $this->assertResponseCode($this->client->getResponse(), Response::HTTP_NO_CONTENT); - } - - /** @test */ - public function it_does_not_delete_the_promotion_in_use(): void - { - $fixtures = $this->loadFixturesFromFiles([ - 'authentication/api_administrator.yaml', - 'channel.yaml', - 'promotion/promotion.yaml', - 'promotion/promotion_order.yaml', - ]); - $header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER); - /** @var PromotionInterface $promotion */ - $promotion = $fixtures['promotion_50_off']; - - $this->client->request( - method: 'DELETE', - uri: sprintf('/api/v2/admin/promotions/%s', $promotion->getCode()), - server: $header, - ); - - $this->assertResponseCode($this->client->getResponse(), Response::HTTP_UNPROCESSABLE_ENTITY); - } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 53c93b699a..a264503816 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -860,21 +860,6 @@ parameters: count: 1 path: src/Sylius/Bundle/ApiBundle/DataPersister/PromotionCouponDataPersister.php - - - message: "#^Method Sylius\\\\Bundle\\\\ApiBundle\\\\DataPersister\\\\PromotionDataPersister\\:\\:persist\\(\\) has parameter \\$data with no type specified\\.$#" - count: 1 - path: src/Sylius/Bundle/ApiBundle/DataPersister/PromotionDataPersister.php - - - - message: "#^Method Sylius\\\\Bundle\\\\ApiBundle\\\\DataPersister\\\\PromotionDataPersister\\:\\:remove\\(\\) has parameter \\$data with no type specified\\.$#" - count: 1 - path: src/Sylius/Bundle/ApiBundle/DataPersister/PromotionDataPersister.php - - - - message: "#^Method Sylius\\\\Bundle\\\\ApiBundle\\\\DataPersister\\\\PromotionDataPersister\\:\\:supports\\(\\) has parameter \\$data with no type specified\\.$#" - count: 1 - path: src/Sylius/Bundle/ApiBundle/DataPersister/PromotionDataPersister.php - - message: "#^Method Sylius\\\\Bundle\\\\ApiBundle\\\\DataPersister\\\\TranslatableDataPersister\\:\\:supports\\(\\) has parameter \\$data with no type specified\\.$#" count: 1 diff --git a/src/Sylius/Bundle/ApiBundle/DataPersister/PromotionDataPersister.php b/src/Sylius/Bundle/ApiBundle/DataPersister/PromotionDataPersister.php deleted file mode 100644 index 075922675c..0000000000 --- a/src/Sylius/Bundle/ApiBundle/DataPersister/PromotionDataPersister.php +++ /dev/null @@ -1,48 +0,0 @@ - $context */ - public function supports($data, array $context = []): bool - { - return $data instanceof PromotionInterface; - } - - /** @param array $context */ - public function persist($data, array $context = []) - { - return $this->decoratedDataPersister->persist($data, $context); - } - - /** @param array $context */ - public function remove($data, array $context = []): void - { - try { - $this->decoratedDataPersister->remove($data, $context); - } catch (ForeignKeyConstraintViolationException) { - throw new PromotionCannotBeRemoved(); - } - } -} diff --git a/src/Sylius/Bundle/ApiBundle/Doctrine/ORM/QueryExtension/Common/RestrictingFilterEagerLoadingExtension.php b/src/Sylius/Bundle/ApiBundle/Doctrine/ORM/QueryExtension/Common/RestrictingFilterEagerLoadingExtension.php index 3fb7bfadac..878dcb4df3 100644 --- a/src/Sylius/Bundle/ApiBundle/Doctrine/ORM/QueryExtension/Common/RestrictingFilterEagerLoadingExtension.php +++ b/src/Sylius/Bundle/ApiBundle/Doctrine/ORM/QueryExtension/Common/RestrictingFilterEagerLoadingExtension.php @@ -29,7 +29,7 @@ final readonly class RestrictingFilterEagerLoadingExtension implements QueryColl */ public function __construct( private QueryCollectionExtensionInterface $decoratedExtension, - private array $restrictedResources + private array $restrictedResources, ) { } diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/api_platform/properties/Promotion.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/api_platform/properties/Promotion.xml new file mode 100644 index 0000000000..36bc98d2d1 --- /dev/null +++ b/src/Sylius/Bundle/ApiBundle/Resources/config/api_platform/properties/Promotion.xml @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/api_platform/properties/PromotionTranslation.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/api_platform/properties/PromotionTranslation.xml new file mode 100644 index 0000000000..5ad367c4cd --- /dev/null +++ b/src/Sylius/Bundle/ApiBundle/Resources/config/api_platform/properties/PromotionTranslation.xml @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/api_platform/resources/ProductVariantTranslation.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/api_platform/resources/ProductVariantTranslation.xml index 7806ad8b03..8b2e32acb2 100644 --- a/src/Sylius/Bundle/ApiBundle/Resources/config/api_platform/resources/ProductVariantTranslation.xml +++ b/src/Sylius/Bundle/ApiBundle/Resources/config/api_platform/resources/ProductVariantTranslation.xml @@ -28,7 +28,6 @@ - @@ -41,8 +40,6 @@ - - diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/api_platform/resources/Promotion.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/api_platform/resources/Promotion.xml new file mode 100644 index 0000000000..4f04b79498 --- /dev/null +++ b/src/Sylius/Bundle/ApiBundle/Resources/config/api_platform/resources/Promotion.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + sylius:admin:promotion:show + + + + + + + + + + diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/api_platform/resources/PromotionTranslation.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/api_platform/resources/PromotionTranslation.xml new file mode 100644 index 0000000000..664bc3349d --- /dev/null +++ b/src/Sylius/Bundle/ApiBundle/Resources/config/api_platform/resources/PromotionTranslation.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/legacy_api_resources/Promotion.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/legacy_api_resources/Promotion.xml index 74b3a67e7b..e97ddde69c 100644 --- a/src/Sylius/Bundle/ApiBundle/Resources/config/legacy_api_resources/Promotion.xml +++ b/src/Sylius/Bundle/ApiBundle/Resources/config/legacy_api_resources/Promotion.xml @@ -95,18 +95,6 @@ Example configuration for `order_fixed_discount` action type: - - GET - - - admin:promotion:show - sylius:admin:promotion:show - - - false - - - PUT @@ -185,10 +173,6 @@ Example configuration for `order_fixed_discount` action type: - - - DELETE - diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/legacy_api_resources/PromotionTranslation.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/legacy_api_resources/PromotionTranslation.xml deleted file mode 100644 index 67b944f395..0000000000 --- a/src/Sylius/Bundle/ApiBundle/Resources/config/legacy_api_resources/PromotionTranslation.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - sylius - - - - - - GET - /admin/promotion-translations/{id} - - - - - - - - diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/Promotion.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/Promotion.xml index cb42f7fbc3..9fc7f49662 100644 --- a/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/Promotion.xml +++ b/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/Promotion.xml @@ -13,195 +13,103 @@ > - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:create - sylius:admin:promotion:create - admin:promotion:update - sylius:admin:promotion:update - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:create - sylius:admin:promotion:create - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:create - sylius:admin:promotion:create - admin:promotion:update - sylius:admin:promotion:update - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:create - sylius:admin:promotion:create - admin:promotion:update - sylius:admin:promotion:update - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:create - sylius:admin:promotion:create - admin:promotion:update - sylius:admin:promotion:update - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:create - sylius:admin:promotion:create - admin:promotion:update - sylius:admin:promotion:update - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:create - sylius:admin:promotion:create - admin:promotion:update - sylius:admin:promotion:update - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:create - sylius:admin:promotion:create - admin:promotion:update - sylius:admin:promotion:update - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:create - sylius:admin:promotion:create - admin:promotion:update - sylius:admin:promotion:update - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:create - sylius:admin:promotion:create - admin:promotion:update - sylius:admin:promotion:update - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:create - sylius:admin:promotion:create - admin:promotion:update - sylius:admin:promotion:update - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:create - sylius:admin:promotion:create - admin:promotion:update - sylius:admin:promotion:update - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:create - sylius:admin:promotion:create - admin:promotion:update - sylius:admin:promotion:update - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:create - sylius:admin:promotion:create - admin:promotion:update - sylius:admin:promotion:update - admin:promotion:read - sylius:admin:promotion:read + sylius:admin:promotion:index + sylius:admin:promotion:show diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/PromotionTranslation.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/PromotionTranslation.xml index 0e01f5ece9..31de035862 100644 --- a/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/PromotionTranslation.xml +++ b/src/Sylius/Bundle/ApiBundle/Resources/config/serialization/PromotionTranslation.xml @@ -16,29 +16,9 @@ xsi:schemaLocation="http://symfony.com/schema/dic/serializer-mapping https://symfony.com/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd" > - - admin:promotion:index - sylius:admin:promotion:index - admin:promotion:show - sylius:admin:promotion:show - - - admin:promotion:index sylius:admin:promotion:index - admin:promotion:show sylius:admin:promotion:show - admin:promotion:create - sylius:admin:promotion:create - admin:promotion:update - sylius:admin:promotion:update - - - - admin:promotion:create - sylius:admin:promotion:create - admin:promotion:update - sylius:admin:promotion:update diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/services/data_persisters.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/services/data_persisters.xml index 6b0c106ee6..1ab60dbcfc 100644 --- a/src/Sylius/Bundle/ApiBundle/Resources/config/services/data_persisters.xml +++ b/src/Sylius/Bundle/ApiBundle/Resources/config/services/data_persisters.xml @@ -71,11 +71,6 @@ - - - - - diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/services/state_processors.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/services/state_processors.xml index 19e472704f..1f50ec6057 100644 --- a/src/Sylius/Bundle/ApiBundle/Resources/config/services/state_processors.xml +++ b/src/Sylius/Bundle/ApiBundle/Resources/config/services/state_processors.xml @@ -63,6 +63,11 @@ + + + + + diff --git a/src/Sylius/Bundle/ApiBundle/Serializer/Normalizer/ShippingMethodNormalizer.php b/src/Sylius/Bundle/ApiBundle/Serializer/Normalizer/ShippingMethodNormalizer.php index 255c85564a..01c5fad46c 100644 --- a/src/Sylius/Bundle/ApiBundle/Serializer/Normalizer/ShippingMethodNormalizer.php +++ b/src/Sylius/Bundle/ApiBundle/Serializer/Normalizer/ShippingMethodNormalizer.php @@ -93,8 +93,7 @@ final class ShippingMethodNormalizer implements NormalizerInterface, NormalizerA $data instanceof ShippingMethodInterface && $this->sectionProvider->getSection() instanceof ShopApiSection && $operation instanceof HttpOperation && - isset($operation->getUriVariables()['tokenValue']) && - isset($operation->getUriVariables()['shipmentId']) + isset($operation->getUriVariables()['tokenValue'], $operation->getUriVariables()['shipmentId']) ; } } diff --git a/src/Sylius/Bundle/ApiBundle/StateProcessor/Admin/Promotion/RemoveProcessor.php b/src/Sylius/Bundle/ApiBundle/StateProcessor/Admin/Promotion/RemoveProcessor.php new file mode 100644 index 0000000000..c8d4379c95 --- /dev/null +++ b/src/Sylius/Bundle/ApiBundle/StateProcessor/Admin/Promotion/RemoveProcessor.php @@ -0,0 +1,44 @@ + + */ +final readonly class RemoveProcessor implements ProcessorInterface +{ + public function __construct(private ProcessorInterface $removeProcessor) + { + } + + public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): void + { + Assert::isInstanceOf($data, PromotionInterface::class); + Assert::isInstanceOf($operation, DeleteOperationInterface::class); + + try { + $this->removeProcessor->process($data, $operation, $uriVariables, $context); + } catch (ForeignKeyConstraintViolationException) { + throw new PromotionCannotBeRemoved(); + } + } +} diff --git a/src/Sylius/Bundle/ApiBundle/disabledSpec/DataPersister/PromotionDataPersisterSpec.php b/src/Sylius/Bundle/ApiBundle/disabledSpec/DataPersister/PromotionDataPersisterSpec.php deleted file mode 100644 index c530e90678..0000000000 --- a/src/Sylius/Bundle/ApiBundle/disabledSpec/DataPersister/PromotionDataPersisterSpec.php +++ /dev/null @@ -1,66 +0,0 @@ -beConstructedWith($dataPersister); - } - - function it_is_a_context_aware_persister(): void - { - $this->shouldImplement(ContextAwareDataPersisterInterface::class); - } - - function it_supports_only_promotion(PromotionInterface $promotion): void - { - $this->supports(new \stdClass())->shouldReturn(false); - $this->supports($promotion)->shouldReturn(true); - } - - function it_uses_inner_persister_to_persist_promotion( - ContextAwareDataPersisterInterface $dataPersister, - PromotionInterface $promotion, - ): void { - $dataPersister->persist($promotion, [])->shouldBeCalled(); - - $this->persist($promotion); - } - - function it_throws_cannot_be_removed_exception_if_constraint_fails_on_removal( - ContextAwareDataPersisterInterface $dataPersister, - PromotionInterface $promotion, - ): void { - $dataPersister->remove($promotion, [])->willThrow(ForeignKeyConstraintViolationException::class); - - $this->shouldThrow(PromotionCannotBeRemoved::class)->during('remove', [$promotion]); - } - - function it_uses_inner_persister_to_remove_promotion( - ContextAwareDataPersisterInterface $dataPersister, - PromotionInterface $promotion, - ): void { - $dataPersister->remove($promotion, [])->shouldBeCalled(); - - $this->remove($promotion); - } -} diff --git a/src/Sylius/Bundle/ApiBundle/spec/StateProcessor/Admin/Promotion/RemoveProcessorSpec.php b/src/Sylius/Bundle/ApiBundle/spec/StateProcessor/Admin/Promotion/RemoveProcessorSpec.php new file mode 100644 index 0000000000..6bfe4fd6bb --- /dev/null +++ b/src/Sylius/Bundle/ApiBundle/spec/StateProcessor/Admin/Promotion/RemoveProcessorSpec.php @@ -0,0 +1,71 @@ +beConstructedWith($removeProcessor); + } + + function it_is_a_processor_interface(): void + { + $this->shouldImplement(ProcessorInterface::class); + } + + public function it_processes_remove_operation( + ProcessorInterface $removeProcessor, + Operation $operation, + PromotionInterface $Promotion, + ) { + $operation->implement(DeleteOperationInterface::class); + $removeProcessor->process($Promotion, $operation, [], [])->willReturn(null); + + $this->process($Promotion, $operation, [], [])->shouldReturn(null); + } + + public function it_throws_exception_when_foreign_key_constraint_violation_occurs( + ProcessorInterface $removeProcessor, + Operation $operation, + PromotionInterface $Promotion, + ) { + $operation->implement(DeleteOperationInterface::class); + $removeProcessor->process($Promotion, $operation, [], [])->willThrow(ForeignKeyConstraintViolationException::class); + + $this->shouldThrow(PromotionCannotBeRemoved::class)->during('process', [$Promotion, $operation, [], []]); + } + + public function it_throws_exception_if_operation_is_not_delete( + Operation $operation, + PromotionInterface $Promotion, + ) { + $this->shouldThrow(\InvalidArgumentException::class)->during('process', [$Promotion, $operation, [], []]); + } + + public function it_throws_exception_if_data_is_not_promotion_interface( + Operation $operation, + \stdClass $nonPromotion, + ) { + $this->shouldThrow(\InvalidArgumentException::class)->during('process', [$nonPromotion, $operation, [], []]); + } +} diff --git a/src/Sylius/Bundle/ApiBundle/spec/StateProvider/Common/Adjustment/CollectionProviderSpec.php b/src/Sylius/Bundle/ApiBundle/spec/StateProvider/Common/Adjustment/CollectionProviderSpec.php index 171588f2f3..beec16e4ac 100644 --- a/src/Sylius/Bundle/ApiBundle/spec/StateProvider/Common/Adjustment/CollectionProviderSpec.php +++ b/src/Sylius/Bundle/ApiBundle/spec/StateProvider/Common/Adjustment/CollectionProviderSpec.php @@ -14,7 +14,6 @@ declare(strict_types=1); namespace spec\Sylius\Bundle\ApiBundle\StateProvider\Common\Adjustment; use ApiPlatform\Metadata\GetCollection; -use ApiPlatform\Metadata\Operation; use ApiPlatform\State\ProviderInterface; use Doctrine\Common\Collections\ArrayCollection; use PhpSpec\ObjectBehavior; diff --git a/tests/Api/Admin/PromotionsTest.php b/tests/Api/Admin/PromotionsTest.php new file mode 100644 index 0000000000..e24a08f881 --- /dev/null +++ b/tests/Api/Admin/PromotionsTest.php @@ -0,0 +1,86 @@ +loadFixturesFromFiles(['authentication/api_administrator.yaml', 'channel.yaml', 'promotion/promotion.yaml']); + $header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER); + + /** @var PromotionInterface $promotion */ + $promotion = $fixtures['promotion_50_off']; + + $this->client->request( + method: 'GET', + uri: sprintf('/api/v2/admin/promotions/%s', $promotion->getCode()), + server: $header, + ); + + $this->assertResponse( + $this->client->getResponse(), + 'admin/promotion/get_promotion_response', + Response::HTTP_OK, + ); + } + + /** @test */ + public function it_deletes_a_promotion(): void + { + $fixtures = $this->loadFixturesFromFiles(['authentication/api_administrator.yaml', 'channel.yaml', 'promotion/promotion.yaml']); + $header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER); + + /** @var PromotionInterface $promotion */ + $promotion = $fixtures['promotion_50_off']; + + $this->client->request( + method: 'DELETE', + uri: sprintf('/api/v2/admin/promotions/%s', $promotion->getCode()), + server: $header, + ); + + $this->assertResponseCode($this->client->getResponse(), Response::HTTP_NO_CONTENT); + } + + /** @test */ + public function it_does_not_delete_the_promotion_in_use(): void + { + $fixtures = $this->loadFixturesFromFiles([ + 'authentication/api_administrator.yaml', + 'channel.yaml', + 'promotion/promotion.yaml', + 'promotion/promotion_order.yaml', + ]); + $header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER); + /** @var PromotionInterface $promotion */ + $promotion = $fixtures['promotion_50_off']; + + $this->client->request( + method: 'DELETE', + uri: sprintf('/api/v2/admin/promotions/%s', $promotion->getCode()), + server: $header, + ); + + $this->assertResponseCode($this->client->getResponse(), Response::HTTP_UNPROCESSABLE_ENTITY); + } +} diff --git a/tests/Api/Responses/admin/promotion/get_promotion_response.json b/tests/Api/Responses/admin/promotion/get_promotion_response.json index 27935f5910..44eef0e160 100644 --- a/tests/Api/Responses/admin/promotion/get_promotion_response.json +++ b/tests/Api/Responses/admin/promotion/get_promotion_response.json @@ -25,9 +25,8 @@ "updatedAt": "@date@", "translations": { "en_US": { - "@id": "\/api\/v2\/admin\/promotion-translations\/@integer@", + "@id": "\/api\/v2\/admin\/promotions\/50_off\/translations\/en_US", "@type": "PromotionTranslation", - "id": "@integer@", "label": "-50% on first order!" } }