|
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\Admin\ShippingMethod; |
|
13
|
|
|
|
|
14
|
|
|
use Behat\Mink\Driver\Selenium2Driver; |
|
15
|
|
|
use Sylius\Behat\Behaviour\ChoosesCalculator; |
|
16
|
|
|
use Sylius\Behat\Behaviour\SpecifiesItsAmount; |
|
17
|
|
|
use Sylius\Behat\Behaviour\SpecifiesItsCode; |
|
18
|
|
|
use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @author Łukasz Chruściel <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
class CreatePage extends BaseCreatePage implements CreatePageInterface |
|
24
|
|
|
{ |
|
25
|
|
|
use SpecifiesItsCode; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* {@inheritdoc} |
|
29
|
|
|
*/ |
|
30
|
|
|
public function specifyPosition($position) |
|
31
|
|
|
{ |
|
32
|
|
|
$this->getDocument()->fillField('Position', $position); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* {@inheritdoc} |
|
37
|
|
|
*/ |
|
38
|
|
|
public function nameIt($name, $language) |
|
39
|
|
|
{ |
|
40
|
|
|
$this->getDocument()->fillField(sprintf('sylius_shipping_method_translations_%s_name', $language), $name); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* {@inheritdoc} |
|
45
|
|
|
*/ |
|
46
|
|
|
public function describeIt($description, $languageCode) |
|
47
|
|
|
{ |
|
48
|
|
|
$this->getDocument()->fillField( |
|
49
|
|
|
sprintf('sylius_shipping_method_translations_%s_description', $languageCode), $description |
|
50
|
|
|
); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* {@inheritdoc} |
|
55
|
|
|
*/ |
|
56
|
|
|
public function specifyAmount($amount) |
|
57
|
|
|
{ |
|
58
|
|
|
$this->getDocument()->fillField('Amount', $amount); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* {@inheritdoc} |
|
63
|
|
|
*/ |
|
64
|
|
|
public function chooseZone($name) |
|
65
|
|
|
{ |
|
66
|
|
|
$this->getDocument()->selectFieldOption('Zone', $name); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* {@inheritdoc} |
|
71
|
|
|
*/ |
|
72
|
|
|
public function chooseCalculator($name) |
|
73
|
|
|
{ |
|
74
|
|
|
$this->getDocument()->selectFieldOption('Calculator', $name); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* {@inheritdoc} |
|
79
|
|
|
*/ |
|
80
|
|
|
public function checkChannel($channelName) |
|
81
|
|
|
{ |
|
82
|
|
|
if ($this->getDriver() instanceof Selenium2Driver) { |
|
83
|
|
|
$this->getElement('channel', ['%channel%' => $channelName])->click(); |
|
84
|
|
|
|
|
85
|
|
|
return; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
$this->getDocument()->checkField($channelName); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* {@inheritdoc} |
|
93
|
|
|
*/ |
|
94
|
|
|
protected function getDefinedElements() |
|
95
|
|
|
{ |
|
96
|
|
|
return array_merge(parent::getDefinedElements(), [ |
|
97
|
|
|
'amount' => '#sylius_shipping_method_configuration_amount', |
|
98
|
|
|
'channel' => '#sylius_shipping_method_channels .ui.checkbox:contains("%channel%")', |
|
99
|
|
|
'calculator' => '#sylius_shipping_method_calculator', |
|
100
|
|
|
'code' => '#sylius_shipping_method_code', |
|
101
|
|
|
'name' => '#sylius_shipping_method_translations_en_US_name', |
|
102
|
|
|
'zone' => '#sylius_shipping_method_zone', |
|
103
|
|
|
]); |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|