Completed
Push — master ( 7c0075...645752 )
by Kamil
18:52
created

CreatePage::chooseBaseCurrency()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 2
eloc 4
nc 2
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
namespace Sylius\Behat\Page\Admin\Channel;
13
14
use Sylius\Behat\Behaviour\DescribesIt;
15
use Sylius\Behat\Behaviour\NamesIt;
16
use Sylius\Behat\Behaviour\SpecifiesItsCode;
17
use Sylius\Behat\Behaviour\Toggles;
18
use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage;
19
20
/**
21
 * @author Kamil Kokot <[email protected]>
22
 */
23
class CreatePage extends BaseCreatePage implements CreatePageInterface
24
{
25
    use NamesIt;
26
    use SpecifiesItsCode;
27
    use DescribesIt;
28
    use Toggles;
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function setHostname($hostname)
34
    {
35
        $this->getDocument()->fillField('Hostname', $hostname);
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function defineColor($color)
42
    {
43
        $this->getDocument()->fillField('Color', $color);
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function chooseCurrency($currencyCode)
50
    {
51
        $this->getDocument()->selectFieldOption('Currencies', $currencyCode);
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function chooseLocale($language)
58
    {
59
        $this->getDocument()->selectFieldOption('Locales', $language);
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function chooseDefaultTaxZone($taxZone)
66
    {
67
        $this->getDocument()->selectFieldOption('Default tax zone', $taxZone);
68
    }
69
70
    /**
71
     * {@inheritdoc}
72
     */
73
    public function chooseDefaultLocale($locale)
74
    {
75
        if (null !== $locale) {
76
            $this->getElement('locales')->selectOption($locale);
77
            $this->getElement('default_locale')->selectOption($locale);
78
        }
79
    }
80
81
    /**
82
     * {@inheritdoc}
83
     */
84
    public function chooseBaseCurrency($currency)
85
    {
86
        if (null !== $currency) {
87
            $this->getElement('currencies')->selectOption($currency);
88
            $this->getElement('base_currency')->selectOption($currency);
89
        }
90
    }
91
92
    /**
93
     * {@inheritdoc}
94
     */
95
    public function chooseTaxCalculationStrategy($taxZone)
96
    {
97
        $this->getDocument()->selectFieldOption('Tax calculation strategy', $taxZone);
98
    }
99
100
    /**
101
     * {@inheritdoc}
102
     */
103
    protected function getToggleableElement()
104
    {
105
        return $this->getElement('enabled');
106
    }
107
108
    /**
109
     * {@inheritdoc}
110
     */
111
    protected function getDefinedElements()
112
    {
113
        return array_merge(parent::getDefinedElements(), [
114
            'code' => '#sylius_channel_code',
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
            'name' => '#sylius_channel_name',
121
        ]);
122
    }
123
}
124