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\Page\Admin\Channel; |
15
|
|
|
|
16
|
|
|
use Behat\Mink\Element\NodeElement; |
17
|
|
|
use Sylius\Behat\Behaviour\ChecksCodeImmutability; |
18
|
|
|
use Sylius\Behat\Behaviour\Toggles; |
19
|
|
|
use Sylius\Behat\Page\Admin\Crud\UpdatePage as BaseUpdatePage; |
20
|
|
|
use Sylius\Behat\Service\AutocompleteHelper; |
21
|
|
|
|
22
|
|
|
class UpdatePage extends BaseUpdatePage implements UpdatePageInterface |
23
|
|
|
{ |
24
|
|
|
use ChecksCodeImmutability; |
25
|
|
|
use Toggles; |
26
|
|
|
|
27
|
|
|
public function setTheme(string $themeName): void |
28
|
|
|
{ |
29
|
|
|
$this->getDocument()->selectFieldOption('Theme', $themeName); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function unsetTheme(): void |
33
|
|
|
{ |
34
|
|
|
$this->getDocument()->selectFieldOption('Theme', ''); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function chooseLocale(string $language): void |
38
|
|
|
{ |
39
|
|
|
$this->getDocument()->selectFieldOption('Locales', $language); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function chooseCurrency(string $currencyCode): void |
43
|
|
|
{ |
44
|
|
|
$this->getDocument()->selectFieldOption('Currencies', $currencyCode); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function chooseDefaultTaxZone(string $taxZone): void |
48
|
|
|
{ |
49
|
|
|
$this->getDocument()->selectFieldOption('Default tax zone', $taxZone); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function chooseTaxCalculationStrategy(string $taxZone): void |
53
|
|
|
{ |
54
|
|
|
$this->getDocument()->selectFieldOption('Tax calculation strategy', $taxZone); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function isLocaleChosen(string $language): bool |
58
|
|
|
{ |
59
|
|
|
return $this->getElement('locales')->find('named', ['option', $language])->hasAttribute('selected'); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function isCurrencyChosen(string $currencyCode): bool |
63
|
|
|
{ |
64
|
|
|
return $this->getElement('currencies')->find('named', ['option', $currencyCode])->hasAttribute('selected'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function isDefaultTaxZoneChosen(string $taxZone): bool |
68
|
|
|
{ |
69
|
|
|
return $this->getElement('default_tax_zone')->find('named', ['option', $taxZone])->hasAttribute('selected'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function isAnyDefaultTaxZoneChosen(): bool |
73
|
|
|
{ |
74
|
|
|
return null !== $this->getElement('default_tax_zone')->find('css', '[selected]'); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function isTaxCalculationStrategyChosen(string $taxCalculationStrategy): bool |
78
|
|
|
{ |
79
|
|
|
return $this |
80
|
|
|
->getElement('tax_calculation_strategy') |
81
|
|
|
->find('named', ['option', $taxCalculationStrategy]) |
82
|
|
|
->hasAttribute('selected') |
83
|
|
|
; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function isBaseCurrencyDisabled(): bool |
87
|
|
|
{ |
88
|
|
|
return $this->getElement('base_currency')->hasAttribute('disabled'); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function changeMenuTaxon(string $menuTaxon): void |
92
|
|
|
{ |
93
|
|
|
$menuTaxonElement = $this->getElement('menu_taxon')->getParent(); |
94
|
|
|
|
95
|
|
|
AutocompleteHelper::chooseValue($this->getSession(), $menuTaxonElement, $menuTaxon); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function getMenuTaxon(): string |
99
|
|
|
{ |
100
|
|
|
return $this->getElement('menu_taxon')->getParent()->find('css', '.search > .text')->getText(); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function getUsedTheme(): string |
104
|
|
|
{ |
105
|
|
|
return $this->getElement('theme')->getValue(); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
protected function getCodeElement(): NodeElement |
109
|
|
|
{ |
110
|
|
|
return $this->getElement('code'); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
protected function getToggleableElement(): NodeElement |
114
|
|
|
{ |
115
|
|
|
return $this->getElement('enabled'); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
protected function getDefinedElements(): array |
119
|
|
|
{ |
120
|
|
|
return array_merge(parent::getDefinedElements(), [ |
121
|
|
|
'base_currency' => '#sylius_channel_baseCurrency', |
122
|
|
|
'code' => '#sylius_channel_code', |
123
|
|
|
'currencies' => '#sylius_channel_currencies', |
124
|
|
|
'default_locale' => '#sylius_channel_defaultLocale', |
125
|
|
|
'default_tax_zone' => '#sylius_channel_defaultTaxZone', |
126
|
|
|
'enabled' => '#sylius_channel_enabled', |
127
|
|
|
'locales' => '#sylius_channel_locales', |
128
|
|
|
'menu_taxon' => '#sylius_channel_menuTaxon', |
129
|
|
|
'name' => '#sylius_channel_name', |
130
|
|
|
'tax_calculation_strategy' => '#sylius_channel_taxCalculationStrategy', |
131
|
|
|
]); |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|