|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Spryker Commerce OS. |
|
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
declare(strict_types = 1); |
|
9
|
|
|
|
|
10
|
|
|
namespace PyzTest\Glue\CartReorder\RestApi; |
|
11
|
|
|
|
|
12
|
|
|
use Codeception\Util\HttpCode; |
|
13
|
|
|
use PyzTest\Glue\CartReorder\CartReorderApiTester; |
|
14
|
|
|
use PyzTest\Glue\CartReorder\RestApi\Fixtures\ProductBundleCartReorderRestApiFixtures; |
|
15
|
|
|
use Spryker\Glue\CartReorderRestApi\CartReorderRestApiConfig; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Auto-generated group annotations |
|
19
|
|
|
* |
|
20
|
|
|
* @group PyzTest |
|
21
|
|
|
* @group Glue |
|
22
|
|
|
* @group CartReorder |
|
23
|
|
|
* @group RestApi |
|
24
|
|
|
* @group ProductBundleCartReorderRestApiCest |
|
25
|
|
|
* Add your own group annotations below this line |
|
26
|
|
|
* @group EndToEnd |
|
27
|
|
|
*/ |
|
28
|
|
|
class ProductBundleCartReorderRestApiCest |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* @var \PyzTest\Glue\CartReorder\RestApi\Fixtures\ProductBundleCartReorderRestApiFixtures |
|
32
|
|
|
*/ |
|
33
|
|
|
protected ProductBundleCartReorderRestApiFixtures $fixtures; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @param \PyzTest\Glue\CartReorder\CartReorderApiTester $I |
|
37
|
|
|
* |
|
38
|
|
|
* @return void |
|
39
|
|
|
*/ |
|
40
|
|
|
public function loadFixtures(CartReorderApiTester $I): void |
|
41
|
|
|
{ |
|
42
|
|
|
/** @var \PyzTest\Glue\CartReorder\RestApi\Fixtures\ProductBundleCartReorderRestApiFixtures $fixtures */ |
|
43
|
|
|
$fixtures = $I->loadFixtures(ProductBundleCartReorderRestApiFixtures::class); |
|
44
|
|
|
|
|
45
|
|
|
$this->fixtures = $fixtures; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @param \PyzTest\Glue\CartReorder\CartReorderApiTester $I |
|
50
|
|
|
* |
|
51
|
|
|
* @return void |
|
52
|
|
|
*/ |
|
53
|
|
|
public function requestCreateCartReorder(CartReorderApiTester $I): void |
|
54
|
|
|
{ |
|
55
|
|
|
// Arrange |
|
56
|
|
|
$I->authorizeCustomerToGlue($this->fixtures->getCustomerTransfer()); |
|
57
|
|
|
|
|
58
|
|
|
$saveOrderTransfer = $this->fixtures->getOrderWithProductBundle(); |
|
59
|
|
|
$requestPayload = [ |
|
60
|
|
|
'data' => [ |
|
61
|
|
|
'type' => CartReorderRestApiConfig::RESOURCE_CART_REORDER, |
|
62
|
|
|
'attributes' => [ |
|
63
|
|
|
'orderReference' => $saveOrderTransfer->getOrderReferenceOrFail(), |
|
64
|
|
|
], |
|
65
|
|
|
], |
|
66
|
|
|
]; |
|
67
|
|
|
|
|
68
|
|
|
// Act |
|
69
|
|
|
$I->sendPost($I->getCartReorderUrl(), $requestPayload); |
|
70
|
|
|
|
|
71
|
|
|
// Assert |
|
72
|
|
|
$I->seeResponseCodeIs(HttpCode::CREATED); |
|
73
|
|
|
$I->seeResponseIsJson(); |
|
74
|
|
|
$I->seeResponseMatchesOpenApiSchema(); |
|
75
|
|
|
|
|
76
|
|
|
$I->amSure('The returned resource is of correct type.') |
|
77
|
|
|
->whenI() |
|
78
|
|
|
->seeResponseDataContainsSingleResourceOfType(CartReorderApiTester::RESOURCE_CARTS); |
|
|
|
|
|
|
79
|
|
|
|
|
80
|
|
|
$I->amSure('The returned response includes first item.') |
|
81
|
|
|
->whenI() |
|
82
|
|
|
->assertResponseContainsItemBySku($this->fixtures->getProductConcreteTransfer()->getSkuOrFail()); |
|
|
|
|
|
|
83
|
|
|
$I->amSure('The first item has correct quantity.') |
|
84
|
|
|
->whenI() |
|
85
|
|
|
->assertItemHasCorrectQuantity($this->fixtures->getProductConcreteTransfer()->getSkuOrFail(), 1); |
|
|
|
|
|
|
86
|
|
|
|
|
87
|
|
|
$I->amSure('The returned response includes bundle item.') |
|
88
|
|
|
->whenI() |
|
89
|
|
|
->assertResponseContainsBundleItemBySku($this->fixtures->getProductBundleTransfer()->getSkuOrFail()); |
|
|
|
|
|
|
90
|
|
|
$I->amSure('The bundle item has correct quantity.') |
|
91
|
|
|
->whenI() |
|
92
|
|
|
->assertBundleItemHasCorrectQuantity( |
|
|
|
|
|
|
93
|
|
|
$this->fixtures->getProductBundleTransfer()->getSkuOrFail(), |
|
94
|
|
|
2, |
|
95
|
|
|
); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|