mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-05 20:57:12 +00:00
[Unit] Add test cases for promotion coupon with non-existing promotion
This commit is contained in:
parent
7d8d85a4ba
commit
5ba8d3159e
2 changed files with 98 additions and 1 deletions
|
|
@ -49,7 +49,7 @@ final class PromotionCouponsTest extends JsonApiTestCase
|
|||
}
|
||||
|
||||
/** @test */
|
||||
public function it_gets_specific_promotion_coupons(): void
|
||||
public function it_gets_promotion_coupons_for_specific_promotion(): void
|
||||
{
|
||||
$fixtures = $this->loadFixturesFromFiles(['authentication/api_administrator.yaml', 'channel/channel.yaml', 'promotion/promotion.yaml']);
|
||||
|
||||
|
|
@ -61,6 +61,16 @@ final class PromotionCouponsTest extends JsonApiTestCase
|
|||
$this->assertResponseSuccessful('admin/promotion_coupon/get_promotion_coupons_response');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_gets_an_empty_array_result_when_the_promotion_has_not_exist(): void
|
||||
{
|
||||
$this->loadFixturesFromFiles(['authentication/api_administrator.yaml']);
|
||||
|
||||
$this->requestGet('/api/v2/admin/promotions/NON_EXISTING_PROMOTION_CODE/coupons');
|
||||
|
||||
$this->assertResponseSuccessful('admin/promotion_coupon/get_empty_promotion_coupons_response');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_creates_a_promotion_coupon(): void
|
||||
{
|
||||
|
|
@ -83,6 +93,25 @@ final class PromotionCouponsTest extends JsonApiTestCase
|
|||
$this->assertResponseCreated('admin/promotion_coupon/post_promotion_coupon_response');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_does_not_create_promotion_coupon_if_promotion_does_not_exist(): void
|
||||
{
|
||||
$this->loadFixturesFromFile('authentication/api_administrator.yaml');
|
||||
|
||||
$this->requestPost(
|
||||
'/api/v2/admin/promotions/NON_EXISTING_PROMOTION_CODE/coupons',
|
||||
[
|
||||
'code' => 'XYZ3',
|
||||
'usageLimit' => 100,
|
||||
'perCustomerUsageLimit' => 3,
|
||||
'reusableFromCancelledOrders' => false,
|
||||
'expiresAt' => '23-12-2023',
|
||||
],
|
||||
);
|
||||
|
||||
$this->assertResponseNotFound('Parent resource not found.');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_updates_a_promotion_coupon(): void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
"@context": "\/api\/v2\/contexts\/PromotionCoupon",
|
||||
"@id": "\/api\/v2\/admin\/promotions\/NON_EXISTING_PROMOTION_CODE\/coupons",
|
||||
"@type": "hydra:Collection",
|
||||
"hydra:totalItems": 0,
|
||||
"hydra:member": [],
|
||||
"hydra:search": {
|
||||
"@type": "hydra:IriTemplate",
|
||||
"hydra:template": "\/api\/v2\/admin\/promotions\/NON_EXISTING_PROMOTION_CODE\/coupons{?order[code],order[expiresAt],order[usageLimit],order[perCustomerUsageLimit],order[used],code,code[],promotion.code,promotion.code[]}",
|
||||
"hydra:variableRepresentation": "BasicRepresentation",
|
||||
"hydra:mapping": [
|
||||
{
|
||||
"@type": "IriTemplateMapping",
|
||||
"variable": "order[code]",
|
||||
"property": "code",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"@type": "IriTemplateMapping",
|
||||
"variable": "order[expiresAt]",
|
||||
"property": "expiresAt",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"@type": "IriTemplateMapping",
|
||||
"variable": "order[usageLimit]",
|
||||
"property": "usageLimit",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"@type": "IriTemplateMapping",
|
||||
"variable": "order[perCustomerUsageLimit]",
|
||||
"property": "perCustomerUsageLimit",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"@type": "IriTemplateMapping",
|
||||
"variable": "order[used]",
|
||||
"property": "used",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"@type": "IriTemplateMapping",
|
||||
"variable": "code",
|
||||
"property": "code",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"@type": "IriTemplateMapping",
|
||||
"variable": "code[]",
|
||||
"property": "code",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"@type": "IriTemplateMapping",
|
||||
"variable": "promotion.code",
|
||||
"property": "promotion.code",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"@type": "IriTemplateMapping",
|
||||
"variable": "promotion.code[]",
|
||||
"property": "promotion.code",
|
||||
"required": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue