|
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
|
|
|
namespace Sylius\Behat\Page\Product; |
|
13
|
|
|
|
|
14
|
|
|
use Sylius\Behat\SymfonyPageObjectExtension\PageObject\SymfonyPage; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @author Arkadiusz Krakowiak <[email protected]> |
|
18
|
|
|
*/ |
|
19
|
|
|
class ProductShowPage extends SymfonyPage |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @param array $urlParameters |
|
23
|
|
|
* |
|
24
|
|
|
* @return ProductShowPage |
|
25
|
|
|
*/ |
|
26
|
|
|
public function open(array $urlParameters = []) |
|
27
|
|
|
{ |
|
28
|
|
|
$url = $this->router->generate($urlParameters['product']); |
|
29
|
|
|
$this->getSession()->visit($url); |
|
30
|
|
|
|
|
31
|
|
|
return $this; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function addToCart() |
|
35
|
|
|
{ |
|
36
|
|
|
$this->getDocument()->pressButton('Add to cart'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @param string $quantity |
|
41
|
|
|
*/ |
|
42
|
|
|
public function addToCartWithQuantity($quantity) |
|
43
|
|
|
{ |
|
44
|
|
|
$this->getDocument()->fillField('Quantity', $quantity); |
|
45
|
|
|
$this->getDocument()->pressButton('Add to cart'); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @param string $variant |
|
50
|
|
|
*/ |
|
51
|
|
|
public function addToCartWithVariant($variant) |
|
52
|
|
|
{ |
|
53
|
|
|
$item = $this->getDocument()->find('css', sprintf('#product-variants tbody tr:contains("%s")', $variant)); |
|
54
|
|
|
$radio = $item->find('css', 'input'); |
|
55
|
|
|
|
|
56
|
|
|
$this->getDocument()->fillField($radio->getAttribute('name'), $radio->getAttribute('value')); |
|
57
|
|
|
|
|
58
|
|
|
$this->getDocument()->pressButton('Add to cart'); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* {@inheritdoc} |
|
63
|
|
|
*/ |
|
64
|
|
|
public function getRouteName() |
|
65
|
|
|
{ |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|