Completed
Push — master ( 0f478c...b73fd3 )
by Kamil
14:27 queued 08:29
created

CreatePage::setType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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\DescribesIt;
18
use Sylius\Behat\Behaviour\NamesIt;
19
use Sylius\Behat\Behaviour\SpecifiesItsCode;
20
use Sylius\Behat\Behaviour\Toggles;
21
use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage;
22
use Sylius\Behat\Service\AutocompleteHelper;
23
24
class CreatePage extends BaseCreatePage implements CreatePageInterface
0 ignored issues
show
Bug introduced by
There is one abstract method getDocument in this class; you could implement it, or declare this class as abstract.
Loading history...
25
{
26
    use NamesIt;
27
    use SpecifiesItsCode;
28
    use DescribesIt;
29
    use Toggles;
30
31
    public function setHostname(string $hostname): void
32
    {
33
        $this->getDocument()->fillField('Hostname', $hostname);
34
    }
35
36
    public function setContactEmail(string $contactEmail): void
37
    {
38
        $this->getDocument()->fillField('Contact email', $contactEmail);
39
    }
40
41
    public function defineColor(string $color): void
42
    {
43
        $this->getDocument()->fillField('Color', $color);
44
    }
45
46
    public function chooseCurrency(string $currencyCode): void
47
    {
48
        $this->getDocument()->selectFieldOption('Currencies', $currencyCode);
49
    }
50
51
    public function chooseLocale(string $language): void
52
    {
53
        $this->getDocument()->selectFieldOption('Locales', $language);
54
    }
55
56
    public function chooseDefaultTaxZone(string $taxZone): void
57
    {
58
        $this->getDocument()->selectFieldOption('Default tax zone', $taxZone);
59
    }
60
61
    public function chooseDefaultLocale(?string $locale): void
62
    {
63
        if (null !== $locale) {
64
            $this->getElement('default_locale')->selectOption($locale);
65
        }
66
    }
67
68
    public function chooseOperatingCountries(array $countries): void
69
    {
70
        foreach ($countries as $country) {
71
            $this->getElement('countries')->selectOption($country, true);
72
        }
73
    }
74
75
    public function chooseBaseCurrency(?string $currency): void
76
    {
77
        if (null !== $currency) {
78
            $this->getElement('currencies')->selectOption($currency);
79
            $this->getElement('base_currency')->selectOption($currency);
80
        }
81
    }
82
83
    public function chooseTaxCalculationStrategy(string $taxZone): void
84
    {
85
        $this->getDocument()->selectFieldOption('Tax calculation strategy', $taxZone);
86
    }
87
88
    public function allowToSkipShippingStep(): void
89
    {
90
        $this->getDocument()->checkField('Skip shipping step if only one shipping method is available?');
91
    }
92
93
    public function allowToSkipPaymentStep(): void
94
    {
95
        $this->getDocument()->checkField('Skip payment step if only one payment method is available?');
96
    }
97
98
    public function specifyMenuTaxon(string $menuTaxon): void
99
    {
100
        $menuTaxonElement = $this->getElement('menu_taxon')->getParent();
101
102
        AutocompleteHelper::chooseValue($this->getSession(), $menuTaxonElement, $menuTaxon);
103
    }
104
105
    protected function getToggleableElement(): NodeElement
106
    {
107
        return $this->getElement('enabled');
108
    }
109
110
    protected function getDefinedElements(): array
111
    {
112
        return array_merge(parent::getDefinedElements(), [
113
            'code' => '#sylius_channel_code',
114
            'countries' => '#sylius_channel_countries',
115
            'currencies' => '#sylius_channel_currencies',
116
            'base_currency' => '#sylius_channel_baseCurrency',
117
            'default_locale' => '#sylius_channel_defaultLocale',
118
            'enabled' => '#sylius_channel_enabled',
119
            'locales' => '#sylius_channel_locales',
120
            'menu_taxon' => '#sylius_channel_menuTaxon',
121
            'name' => '#sylius_channel_name',
122
        ]);
123
    }
124
}
125