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\Shop\Checkout; |
13
|
|
|
|
14
|
|
|
use Behat\Mink\Exception\ElementNotFoundException; |
15
|
|
|
use Sylius\Behat\Page\SymfonyPage; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author Mateusz Zalewski <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class ShippingPage extends SymfonyPage implements ShippingPageInterface |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* {@inheritdoc} |
24
|
|
|
*/ |
25
|
|
|
public function getRouteName() |
26
|
|
|
{ |
27
|
|
|
return 'sylius_shop_checkout_shipping'; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* {@inheritdoc} |
32
|
|
|
*/ |
33
|
|
|
public function selectShippingMethod($shippingMethod) |
34
|
|
|
{ |
35
|
|
|
$shippingMethodElement = $this->getElement('shipping_method'); |
36
|
|
|
$shippingMethodValue = $this->getElement('shipping_method_option', ['%shipping_method%' => $shippingMethod])->getValue(); |
37
|
|
|
|
38
|
|
|
$shippingMethodElement->selectOption($shippingMethodValue); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritdoc} |
43
|
|
|
*/ |
44
|
|
|
public function hasShippingMethod($shippingMethod) |
45
|
|
|
{ |
46
|
|
|
try { |
47
|
|
|
$this->getElement('shipping_method_option', ['%shipping_method%' => $shippingMethod]); |
48
|
|
|
} catch (ElementNotFoundException $exception) { |
49
|
|
|
return false; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
return true; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* {@inheritdoc} |
57
|
|
|
*/ |
58
|
|
|
public function hasNoShippingMethodsMessage() |
59
|
|
|
{ |
60
|
|
|
try { |
61
|
|
|
$this->getElement('order_cannot_be_shipped_message'); |
62
|
|
|
} catch (ElementNotFoundException $exception) { |
63
|
|
|
return false; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
return true; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function nextStep() |
70
|
|
|
{ |
71
|
|
|
$this->getDocument()->pressButton('Next'); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* {@inheritdoc} |
76
|
|
|
*/ |
77
|
|
|
protected function getDefinedElements() |
78
|
|
|
{ |
79
|
|
|
return array_merge(parent::getDefinedElements(), [ |
80
|
|
|
'order_cannot_be_shipped_message' => '#sylius-order-cannot-be-shipped', |
81
|
|
|
'shipping_method' => '[name="sylius_shop_checkout_shipping[shipments][0][method]"]', |
82
|
|
|
'shipping_method_option' => '.item:contains("%shipping_method%") input', |
83
|
|
|
]); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|