|
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
|
|
|
namespace PyzTest\Glue\Products\RestApi; |
|
9
|
|
|
|
|
10
|
|
|
use Codeception\Util\HttpCode; |
|
11
|
|
|
use Pyz\Glue\ProductPricesRestApi\ProductPricesRestApiConfig; |
|
12
|
|
|
use PyzTest\Glue\Products\ProductsApiTester; |
|
13
|
|
|
use PyzTest\Glue\Products\RestApi\Fixtures\ProductsRestApiFixtures; |
|
14
|
|
|
use Spryker\Glue\ProductsRestApi\ProductsRestApiConfig; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Auto-generated group annotations |
|
18
|
|
|
* |
|
19
|
|
|
* @group PyzTest |
|
20
|
|
|
* @group Glue |
|
21
|
|
|
* @group Products |
|
22
|
|
|
* @group RestApi |
|
23
|
|
|
* @group ProductConcreteRestApiCest |
|
24
|
|
|
* Add your own group annotations below this line |
|
25
|
|
|
* @group EndToEnd |
|
26
|
|
|
*/ |
|
27
|
|
|
class ProductConcreteRestApiCest |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* @var \PyzTest\Glue\Products\RestApi\Fixtures\ProductsRestApiFixtures |
|
31
|
|
|
*/ |
|
32
|
|
|
protected ProductsRestApiFixtures $fixtures; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @param \PyzTest\Glue\Products\ProductsApiTester $I |
|
36
|
|
|
* |
|
37
|
|
|
* @return void |
|
38
|
|
|
*/ |
|
39
|
|
|
public function loadFixtures(ProductsApiTester $I): void |
|
40
|
|
|
{ |
|
41
|
|
|
/** @var \PyzTest\Glue\Products\RestApi\Fixtures\ProductsRestApiFixtures $fixtures */ |
|
42
|
|
|
$fixtures = $I->loadFixtures(ProductsRestApiFixtures::class); |
|
43
|
|
|
|
|
44
|
|
|
$this->fixtures = $fixtures; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @depends loadFixtures |
|
49
|
|
|
* |
|
50
|
|
|
* @param \PyzTest\Glue\Products\ProductsApiTester $I |
|
51
|
|
|
* |
|
52
|
|
|
* @return void |
|
53
|
|
|
*/ |
|
54
|
|
|
public function requestProductConcrete(ProductsApiTester $I): void |
|
55
|
|
|
{ |
|
56
|
|
|
// Arrange |
|
57
|
|
|
$productConcreteSku = $this->fixtures->getProductConcreteTransfer()->getSku(); |
|
58
|
|
|
$url = $I->buildProductConcreteUrl($productConcreteSku); |
|
59
|
|
|
|
|
60
|
|
|
// Act |
|
61
|
|
|
$I->sendGET($url); |
|
62
|
|
|
|
|
63
|
|
|
// Assert |
|
64
|
|
|
$I->seeResponseCodeIs(HttpCode::OK); |
|
65
|
|
|
$I->seeResponseIsJson(); |
|
66
|
|
|
$I->seeResponseMatchesOpenApiSchema(); |
|
67
|
|
|
|
|
68
|
|
|
$I->amSure('The returned resource is of correct type') |
|
69
|
|
|
->whenI() |
|
70
|
|
|
->seeResponseDataContainsSingleResourceOfType(ProductsRestApiConfig::RESOURCE_CONCRETE_PRODUCTS); |
|
|
|
|
|
|
71
|
|
|
|
|
72
|
|
|
$I->amSure('The returned resource has correct id') |
|
73
|
|
|
->whenI() |
|
74
|
|
|
->seeSingleResourceIdEqualTo($productConcreteSku); |
|
|
|
|
|
|
75
|
|
|
|
|
76
|
|
|
$I->amSure('The returned resource has correct self-link') |
|
77
|
|
|
->whenI() |
|
78
|
|
|
->seeSingleResourceHasSelfLink($url); |
|
|
|
|
|
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @depends loadFixtures |
|
83
|
|
|
* |
|
84
|
|
|
* @param \PyzTest\Glue\Products\ProductsApiTester $I |
|
85
|
|
|
* |
|
86
|
|
|
* @return void |
|
87
|
|
|
*/ |
|
88
|
|
|
public function requestProductConcreteWithProductPriceRelationship(ProductsApiTester $I): void |
|
89
|
|
|
{ |
|
90
|
|
|
// Arrange |
|
91
|
|
|
$productConcreteSku = $this->fixtures->getProductConcreteTransfer()->getSku(); |
|
92
|
|
|
$url = $I->buildProductConcreteUrl($productConcreteSku, [ProductPricesRestApiConfig::RESOURCE_CONCRETE_PRODUCT_PRICES]); |
|
93
|
|
|
|
|
94
|
|
|
// Act |
|
95
|
|
|
$I->sendGET($url); |
|
96
|
|
|
|
|
97
|
|
|
// Assert |
|
98
|
|
|
$I->seeResponseCodeIs(HttpCode::OK); |
|
99
|
|
|
$I->seeResponseIsJson(); |
|
100
|
|
|
$I->seeResponseMatchesOpenApiSchema(); |
|
101
|
|
|
|
|
102
|
|
|
$I->amSure('The returned resource has relationship') |
|
103
|
|
|
->whenI() |
|
104
|
|
|
->seeSingleResourceHasRelationshipByTypeAndId( |
|
|
|
|
|
|
105
|
|
|
ProductPricesRestApiConfig::RESOURCE_CONCRETE_PRODUCT_PRICES, |
|
106
|
|
|
$productConcreteSku, |
|
107
|
|
|
); |
|
108
|
|
|
|
|
109
|
|
|
$I->amSure('The returned resource has include') |
|
110
|
|
|
->whenI() |
|
111
|
|
|
->seeIncludesContainsResourceByTypeAndId( |
|
|
|
|
|
|
112
|
|
|
ProductPricesRestApiConfig::RESOURCE_CONCRETE_PRODUCT_PRICES, |
|
113
|
|
|
$productConcreteSku, |
|
114
|
|
|
); |
|
115
|
|
|
|
|
116
|
|
|
$I->amSure('The include has correct self-link') |
|
117
|
|
|
->whenI() |
|
118
|
|
|
->seeIncludedResourceByTypeAndIdHasSelfLink( |
|
|
|
|
|
|
119
|
|
|
ProductPricesRestApiConfig::RESOURCE_CONCRETE_PRODUCT_PRICES, |
|
120
|
|
|
$productConcreteSku, |
|
121
|
|
|
$I->buildProductConcretePricesUrl($productConcreteSku), |
|
122
|
|
|
); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @depends loadFixtures |
|
127
|
|
|
* |
|
128
|
|
|
* @param \PyzTest\Glue\Products\ProductsApiTester $I |
|
129
|
|
|
* |
|
130
|
|
|
* @return void |
|
131
|
|
|
*/ |
|
132
|
|
|
public function requestProductConcreteByNotExistingProductConcreteSku(ProductsApiTester $I): void |
|
133
|
|
|
{ |
|
134
|
|
|
// Act |
|
135
|
|
|
$I->sendGET($I->buildProductConcreteUrl('NotExistingSku')); |
|
136
|
|
|
|
|
137
|
|
|
// Assert |
|
138
|
|
|
$I->seeResponseCodeIs(HttpCode::NOT_FOUND); |
|
139
|
|
|
$I->seeResponseIsJson(); |
|
140
|
|
|
$I->seeResponseMatchesOpenApiSchema(); |
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
|