From 854393e2936173c12466c2b38f066d5b4835be8f Mon Sep 17 00:00:00 2001 From: Wojdylak Date: Thu, 23 Nov 2023 16:04:37 +0100 Subject: [PATCH] Add coupons to payload in PromotionCouponsTest --- tests/Api/Admin/PromotionCouponsTest.php | 10 +++++----- .../admin/promotion/get_promotion_response.json | 4 +++- .../admin/promotion/get_promotions_response.json | 16 ++++++++++++---- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/tests/Api/Admin/PromotionCouponsTest.php b/tests/Api/Admin/PromotionCouponsTest.php index b80cbed69a..bc2eb4ce6a 100644 --- a/tests/Api/Admin/PromotionCouponsTest.php +++ b/tests/Api/Admin/PromotionCouponsTest.php @@ -26,7 +26,7 @@ final class PromotionCouponsTest extends JsonApiTestCase /** @test */ public function it_gets_a_promotion_coupon(): void { - $fixtures = $this->loadFixturesFromFiles(['authentication/api_administrator.yaml', 'channel.yaml', 'promotion.yaml']); + $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 PromotionCouponInterface $coupon */ @@ -48,7 +48,7 @@ final class PromotionCouponsTest extends JsonApiTestCase /** @test */ public function it_gets_promotion_coupons(): void { - $this->loadFixturesFromFiles(['authentication/api_administrator.yaml', 'channel.yaml', 'promotion.yaml']); + $this->loadFixturesFromFiles(['authentication/api_administrator.yaml', 'channel.yaml', 'promotion/promotion.yaml']); $header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER); $this->client->request(method: 'GET', uri: '/api/v2/admin/promotion-coupons', server: $header); @@ -63,7 +63,7 @@ final class PromotionCouponsTest extends JsonApiTestCase /** @test */ public function it_creates_a_promotion_coupon(): void { - $fixtures = $this->loadFixturesFromFiles(['authentication/api_administrator.yaml', 'channel.yaml', 'promotion.yaml']); + $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 */ @@ -93,7 +93,7 @@ final class PromotionCouponsTest extends JsonApiTestCase /** @test */ public function it_updates_a_promotion_coupon(): void { - $fixtures = $this->loadFixturesFromFiles(['authentication/api_administrator.yaml', 'channel.yaml', 'promotion.yaml']); + $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 PromotionCouponInterface $coupon */ @@ -121,7 +121,7 @@ final class PromotionCouponsTest extends JsonApiTestCase /** @test */ public function it_removes_a_promotion_coupon(): void { - $fixtures = $this->loadFixturesFromFiles(['authentication/api_administrator.yaml', 'channel.yaml', 'promotion.yaml']); + $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 PromotionCouponInterface $coupon */ diff --git a/tests/Api/Responses/Expected/admin/promotion/get_promotion_response.json b/tests/Api/Responses/Expected/admin/promotion/get_promotion_response.json index 5991030492..457730d357 100644 --- a/tests/Api/Responses/Expected/admin/promotion/get_promotion_response.json +++ b/tests/Api/Responses/Expected/admin/promotion/get_promotion_response.json @@ -6,7 +6,9 @@ "code": "50_off", "name": "50% Off on your first order", "description": "Get 50% off of your first purchase", - "channels": ["\/api\/v2\/admin\/channels\/MOBILE"], + "channels": [ + "\/api\/v2\/admin\/channels\/MOBILE" + ], "priority": 1, "exclusive": true, "appliesToDiscounted": false, diff --git a/tests/Api/Responses/Expected/admin/promotion/get_promotions_response.json b/tests/Api/Responses/Expected/admin/promotion/get_promotions_response.json index 42e62fd170..1b26793039 100644 --- a/tests/Api/Responses/Expected/admin/promotion/get_promotions_response.json +++ b/tests/Api/Responses/Expected/admin/promotion/get_promotions_response.json @@ -10,7 +10,10 @@ "code": "dollar_off", "name": "1 dollar off each item", "description": "Get 1 dollar off every item when buying more than 10", - "channels": ["\/api\/v2\/admin\/channels\/WEB", "\/api\/v2\/admin\/channels\/MOBILE"], + "channels": [ + "\/api\/v2\/admin\/channels\/WEB", + "\/api\/v2\/admin\/channels\/MOBILE" + ], "priority": 2, "exclusive": false, "appliesToDiscounted": true, @@ -19,7 +22,10 @@ "couponBased": true, "startsAt": null, "endsAt": null, - "coupons": [], + "coupons": [ + "\/api\/v2\/admin\/promotion-coupons\/XYZ1", + "\/api\/v2\/admin\/promotion-coupons\/XYZ2" + ], "rules": [], "actions": [], "createdAt": @date@, @@ -40,7 +46,9 @@ "code": "50_off", "name": "50% Off on your first order", "description": "Get 50% off of your first purchase", - "channels": ["\/api\/v2\/admin\/channels\/MOBILE"], + "channels": [ + "\/api\/v2\/admin\/channels\/MOBILE" + ], "priority": 1, "exclusive": true, "appliesToDiscounted": false, @@ -67,7 +75,7 @@ "hydra:totalItems": 2, "hydra:search": { "@type": "hydra:IriTemplate", - "hydra:template": "/api/v2/admin/promotions{?coupons.code,coupons.code[],order[priority]}", + "hydra:template": "\/api\/v2\/admin\/promotions{?coupons.code,coupons.code[],order[priority]}", "hydra:variableRepresentation": "BasicRepresentation", "hydra:mapping": [ {