1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Sylius package. |
5
|
|
|
* |
6
|
|
|
* (c) Paweł Jędrzejewski |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Sylius\Behat\Context\Ui\Admin; |
15
|
|
|
|
16
|
|
|
use Behat\Behat\Context\Context; |
17
|
|
|
use Sylius\Behat\Element\Product\ShowPage\AssociationsElementInterface; |
18
|
|
|
use Sylius\Behat\Element\Product\ShowPage\AttributesElementInterface; |
19
|
|
|
use Sylius\Behat\Element\Product\ShowPage\DetailsElementInterface; |
20
|
|
|
use Sylius\Behat\Element\Product\ShowPage\MediaElementInterface; |
21
|
|
|
use Sylius\Behat\Element\Product\ShowPage\MoreDetailsElementInterface; |
22
|
|
|
use Sylius\Behat\Element\Product\ShowPage\OptionsElementInterface; |
23
|
|
|
use Sylius\Behat\Element\Product\ShowPage\PricingElementInterface; |
24
|
|
|
use Sylius\Behat\Element\Product\ShowPage\ShippingElementInterface; |
25
|
|
|
use Sylius\Behat\Element\Product\ShowPage\TaxonomyElementInterface; |
26
|
|
|
use Sylius\Behat\Element\Product\ShowPage\VariantsElementInterface; |
27
|
|
|
use Sylius\Behat\Page\Admin\Product\IndexPageInterface; |
28
|
|
|
use Sylius\Behat\Page\Admin\Product\ShowPageInterface; |
29
|
|
|
use Sylius\Component\Core\Model\ProductInterface; |
30
|
|
|
use Sylius\Component\Core\Model\ProductVariantInterface; |
31
|
|
|
use Webmozart\Assert\Assert; |
32
|
|
|
|
33
|
|
|
final class ProductShowPageContext implements Context |
34
|
|
|
{ |
35
|
|
|
/** @var IndexPageInterface */ |
36
|
|
|
private $indexPage; |
37
|
|
|
|
38
|
|
|
/** @var ShowPageInterface */ |
39
|
|
|
private $productShowPage; |
40
|
|
|
|
41
|
|
|
/** @var AssociationsElementInterface */ |
42
|
|
|
private $associationsElement; |
43
|
|
|
|
44
|
|
|
/** @var AttributesElementInterface */ |
45
|
|
|
private $attributesElement; |
46
|
|
|
|
47
|
|
|
/** @var DetailsElementInterface */ |
48
|
|
|
private $detailsElement; |
49
|
|
|
|
50
|
|
|
/** @var MediaElementInterface */ |
51
|
|
|
private $mediaElement; |
52
|
|
|
|
53
|
|
|
/** @var MoreDetailsElementInterface */ |
54
|
|
|
private $moreDetailsElement; |
55
|
|
|
|
56
|
|
|
/** @var PricingElementInterface */ |
57
|
|
|
private $pricingElement; |
58
|
|
|
|
59
|
|
|
/** @var ShippingElementInterface */ |
60
|
|
|
private $shippingElement; |
61
|
|
|
|
62
|
|
|
/** @var TaxonomyElementInterface */ |
63
|
|
|
private $taxonomyElement; |
64
|
|
|
|
65
|
|
|
/** @var OptionsElementInterface */ |
66
|
|
|
private $optionsElement; |
67
|
|
|
|
68
|
|
|
/** @var VariantsElementInterface */ |
69
|
|
|
private $variantsElement; |
70
|
|
|
|
71
|
|
|
public function __construct( |
72
|
|
|
IndexPageInterface $indexPage, |
73
|
|
|
ShowPageInterface $productShowPage, |
74
|
|
|
AssociationsElementInterface $associationsElement, |
75
|
|
|
AttributesElementInterface $attributesElement, |
76
|
|
|
DetailsElementInterface $detailsElement, |
77
|
|
|
MediaElementInterface $mediaElement, |
78
|
|
|
MoreDetailsElementInterface $moreDetailsElement, |
79
|
|
|
PricingElementInterface $pricingElement, |
80
|
|
|
ShippingElementInterface $shippingElement, |
81
|
|
|
TaxonomyElementInterface $taxonomyElement, |
82
|
|
|
OptionsElementInterface $optionsElement, |
83
|
|
|
VariantsElementInterface $variantsElement |
84
|
|
|
) { |
85
|
|
|
$this->indexPage = $indexPage; |
86
|
|
|
$this->productShowPage = $productShowPage; |
87
|
|
|
$this->associationsElement = $associationsElement; |
88
|
|
|
$this->attributesElement = $attributesElement; |
89
|
|
|
$this->detailsElement = $detailsElement; |
90
|
|
|
$this->mediaElement = $mediaElement; |
91
|
|
|
$this->moreDetailsElement = $moreDetailsElement; |
92
|
|
|
$this->pricingElement = $pricingElement; |
93
|
|
|
$this->shippingElement = $shippingElement; |
94
|
|
|
$this->taxonomyElement = $taxonomyElement; |
95
|
|
|
$this->optionsElement = $optionsElement; |
96
|
|
|
$this->variantsElement = $variantsElement; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @Given I am browsing products |
101
|
|
|
*/ |
102
|
|
|
public function iAmBrowsingProducts(): void |
103
|
|
|
{ |
104
|
|
|
$this->indexPage->open(); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @When I access :product product page |
109
|
|
|
*/ |
110
|
|
|
public function iAccessProductPage(ProductInterface $product): void |
111
|
|
|
{ |
112
|
|
|
$this->indexPage->showProductPage($product->getName()); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @When I show this product in the :channel channel |
117
|
|
|
*/ |
118
|
|
|
public function iShowThisProductInTheChannel(string $channel): void |
119
|
|
|
{ |
120
|
|
|
$this->productShowPage->showProductInChannel($channel); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @When I show this product in this channel |
125
|
|
|
*/ |
126
|
|
|
public function iShowThisProductInThisChannel(): void |
127
|
|
|
{ |
128
|
|
|
$this->productShowPage->showProductInSingleChannel(); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @When I go to edit page |
133
|
|
|
*/ |
134
|
|
|
public function iGoToEditPage(): void |
135
|
|
|
{ |
136
|
|
|
$this->productShowPage->showProductEditPage(); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @When I go to edit page of :variant variant |
141
|
|
|
*/ |
142
|
|
|
public function iGoToEditPageOfVariant(ProductVariantInterface $variant): void |
143
|
|
|
{ |
144
|
|
|
$this->productShowPage->showVariantEditPage($variant); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @Then I should see this product's product page |
149
|
|
|
*/ |
150
|
|
|
public function iShouldSeeThisProductPage(ProductInterface $product): void |
151
|
|
|
{ |
152
|
|
|
Assert::true($this->productShowPage->isOpen(['id' => $product->getId()])); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @Then I should see product show page without variants |
157
|
|
|
*/ |
158
|
|
|
public function iShouldSeeProductShowPageWithoutVariants(): void |
159
|
|
|
{ |
160
|
|
|
Assert::true($this->productShowPage->isSimpleProductPage()); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @Then I should see product show page with variants |
165
|
|
|
*/ |
166
|
|
|
public function iShouldSeeProductShowPageWithVariants(): void |
167
|
|
|
{ |
168
|
|
|
Assert::false($this->productShowPage->isSimpleProductPage()); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @Then I should see product name :productName |
173
|
|
|
*/ |
174
|
|
|
public function iShouldSeeProductName(string $productName): void |
175
|
|
|
{ |
176
|
|
|
Assert::same($productName, $this->productShowPage->getName()); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* @Then I should see price :price for channel :channelName |
181
|
|
|
*/ |
182
|
|
|
public function iShouldSeePriceForChannel(string $price, string $channelName): void |
183
|
|
|
{ |
184
|
|
|
Assert::same($this->pricingElement->getPriceForChannel($channelName), $price); |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* @Then I should not see price for channel :channelName |
189
|
|
|
*/ |
190
|
|
|
public function iShouldNotSeePriceForChannel(string $channelName): void |
191
|
|
|
{ |
192
|
|
|
Assert::same($this->pricingElement->getPriceForChannel($channelName), ''); |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @Then I should see original price :price for channel :channelName |
197
|
|
|
*/ |
198
|
|
|
public function iShouldSeeOrginalPriceForChannel(string $orginalPrice, string $channelName): void |
199
|
|
|
{ |
200
|
|
|
Assert::same($this->pricingElement->getOriginalPriceForChannel($channelName), $orginalPrice); |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* @Then I should see product's code is :code |
205
|
|
|
*/ |
206
|
|
|
public function iShouldSeeProductCodeIs(string $code): void |
207
|
|
|
{ |
208
|
|
|
Assert::same($this->detailsElement->getProductCode(), $code); |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* @Then I should see the product is enabled for channel :channel |
213
|
|
|
*/ |
214
|
|
|
public function iShouldSeeProductIsEnabledForChannels(string $channel): void |
215
|
|
|
{ |
216
|
|
|
Assert::true($this->detailsElement->hasChannel($channel)); |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* @Then I should see the product in neither channel |
221
|
|
|
*/ |
222
|
|
|
public function iShouldSeeTheProductInNeitherChannel(): void |
223
|
|
|
{ |
224
|
|
|
Assert::same($this->detailsElement->countChannels(), 0); |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* @Then I should see :currentStock as a current stock of this product |
229
|
|
|
*/ |
230
|
|
|
public function iShouldSeeAsACurrentStockOfThisProduct(int $currentStock): void |
231
|
|
|
{ |
232
|
|
|
Assert::same($this->detailsElement->getProductCurrentStock(), $currentStock); |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* @Then I should see product's tax category is :taxCategory |
237
|
|
|
*/ |
238
|
|
|
public function iShouldSeeProductTaxCategoryIs(string $taxCategory): void |
239
|
|
|
{ |
240
|
|
|
Assert::same($this->detailsElement->getProductTaxCategory(), $taxCategory); |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* @Then I should see main taxon is :mainTaxonName |
245
|
|
|
*/ |
246
|
|
|
public function iShouldSeeMainTaxonIs(string $mainTaxonName): void |
247
|
|
|
{ |
248
|
|
|
Assert::same($this->taxonomyElement->getProductMainTaxon(), $mainTaxonName); |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* @Then I should see product taxon is :taxonName |
253
|
|
|
*/ |
254
|
|
|
public function iShouldSeeProductTaxonIs(string $taxonName): void |
255
|
|
|
{ |
256
|
|
|
Assert::true($this->taxonomyElement->hasProductTaxon($taxonName)); |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
/** |
260
|
|
|
* @Then I should see product's shipping category is :shippingCategory |
261
|
|
|
*/ |
262
|
|
|
public function iShouldSeeProductShippingCategoryIs(string $shippingCategory): void |
263
|
|
|
{ |
264
|
|
|
Assert::same($this->shippingElement->getProductShippingCategory(), $shippingCategory); |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* @Then I should see product's width is :width |
269
|
|
|
*/ |
270
|
|
|
public function iShouldSeeProductWidthIs(float $width): void |
271
|
|
|
{ |
272
|
|
|
Assert::same($this->shippingElement->getProductWidth(), $width); |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* @Then I should see product's height is :height |
277
|
|
|
*/ |
278
|
|
|
public function iShouldSeeProductHeightIs(float $height): void |
279
|
|
|
{ |
280
|
|
|
Assert::same($this->shippingElement->getProductHeight(), $height); |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* @Then I should see product's depth is :depth |
285
|
|
|
*/ |
286
|
|
|
public function iShouldSeeProductDepthIs(float $depth): void |
287
|
|
|
{ |
288
|
|
|
Assert::same($this->shippingElement->getProductDepth(), $depth); |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
/** |
292
|
|
|
* @Then I should see product's weight is :weight |
293
|
|
|
*/ |
294
|
|
|
public function iShouldSeeProductWeightIs(float $weight): void |
295
|
|
|
{ |
296
|
|
|
Assert::same($this->shippingElement->getProductWeight(), $weight); |
297
|
|
|
} |
298
|
|
|
|
299
|
|
|
/** |
300
|
|
|
* @Then I should see an image related to this product |
301
|
|
|
*/ |
302
|
|
|
public function iShouldSeeImageRelatedToThisProduct(): void |
303
|
|
|
{ |
304
|
|
|
Assert::true($this->mediaElement->isImageDisplayed()); |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* @Then I should see product name is :name |
309
|
|
|
*/ |
310
|
|
|
public function iShouldSeeProductNameIs(string $name): void |
311
|
|
|
{ |
312
|
|
|
Assert::same($this->moreDetailsElement->getName(), $name); |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* @Then I should see product slug is :slug |
317
|
|
|
*/ |
318
|
|
|
public function iShouldSeeProductSlugIs(string $slug): void |
319
|
|
|
{ |
320
|
|
|
Assert::same($this->moreDetailsElement->getSlug(), $slug); |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
/** |
324
|
|
|
* @Then I should see product's description is :description |
325
|
|
|
*/ |
326
|
|
|
public function iShouldSeeProductSDescriptionIs(string $description): void |
327
|
|
|
{ |
328
|
|
|
Assert::same($this->moreDetailsElement->getDescription(), $description); |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
/** |
332
|
|
|
* @Then I should see product's meta keyword(s) is/are :metaKeywords |
333
|
|
|
*/ |
334
|
|
|
public function iShouldSeeProductMetaKeywordsAre(string $metaKeywords): void |
335
|
|
|
{ |
336
|
|
|
Assert::same($this->moreDetailsElement->getProductMetaKeywords(), $metaKeywords); |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* @Then I should see product's short description is :shortDescription |
341
|
|
|
*/ |
342
|
|
|
public function iShouldSeeProductShortDescriptionIs(string $shortDescription): void |
343
|
|
|
{ |
344
|
|
|
Assert::same($this->moreDetailsElement->getShortDescription(), $shortDescription); |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
/** |
348
|
|
|
* @Then I should see product association :association with :productName |
349
|
|
|
*/ |
350
|
|
|
public function iShouldSeeProductAssociationWith(string $association, string $productName): void |
351
|
|
|
{ |
352
|
|
|
Assert::true($this->associationsElement->isProductAssociated($association, $productName)); |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
/** |
356
|
|
|
* @Then I should see option :optionName |
357
|
|
|
*/ |
358
|
|
|
public function iShouldSeeOption(string $optionName): void |
359
|
|
|
{ |
360
|
|
|
Assert::true($this->optionsElement->isOptionDefined($optionName)); |
361
|
|
|
} |
362
|
|
|
|
363
|
|
|
/** |
364
|
|
|
* @Then I should see :count variants |
365
|
|
|
*/ |
366
|
|
|
public function iShouldSeeVariants(int $count): void |
367
|
|
|
{ |
368
|
|
|
Assert::same($this->variantsElement->countVariantsOnPage(), $count); |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
/** |
372
|
|
|
* @Then I should see :variantName variant with code :code, priced :price and current stock :currentStock |
373
|
|
|
*/ |
374
|
|
|
public function iShouldSeeVariantWithCodePriceAndCurrentStock(string $variantName, string $code, string $price, string $currentStock): void |
375
|
|
|
{ |
376
|
|
|
Assert::true($this->variantsElement->hasProductVariantWithCodePriceAndCurrentStock($variantName, $code, $price, $currentStock)); |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* @Then I should see attribute :attribute with value :value in :locale locale |
381
|
|
|
*/ |
382
|
|
|
public function iShouldSeeAttributeWithValueInLocale(string $attribute, string $value, string $locale): void |
383
|
|
|
{ |
384
|
|
|
Assert::true($this->attributesElement->hasAttributeInLocale($attribute, $locale, $value)); |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
/** |
388
|
|
|
* @Then I should not be able to show this product in shop |
389
|
|
|
*/ |
390
|
|
|
public function iShouldNotBeAbleToShowThisProductInShop(): void |
391
|
|
|
{ |
392
|
|
|
Assert::true($this->productShowPage->isShowInShopButtonDisabled()); |
393
|
|
|
} |
394
|
|
|
} |
395
|
|
|
|