Completed
Push — symfony3-fqcn ( 04e8c2...ea8d6b )
by Kamil
18:56
created

CreatePage::getDefinedElements()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
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\ExchangeRate;
13
14
use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage;
15
16
/**
17
 * @author Jan Góralski <[email protected]>
18
 */
19
class CreatePage extends BaseCreatePage implements CreatePageInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function specifyRatio($ratio)
25
    {
26
        $this->getDocument()->fillField('Ratio', $ratio);
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function chooseSourceCurrency($currency)
33
    {
34
        $this->getDocument()->selectFieldOption('Source currency', $currency);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function chooseTargetCurrency($currency)
41
    {
42
        $this->getDocument()->selectFieldOption('Target currency', $currency);
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function hasFormValidationError($expectedMessage)
49
    {
50
        $formValidationErrors = $this->getDocument()->find('css', 'form > div.ui.red.label.sylius-validation-error');
51
        if (null === $formValidationErrors) {
52
            return false;
53
        }
54
55
        return $expectedMessage === $formValidationErrors->getText();
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    protected function getDefinedElements()
62
    {
63
        return array_merge(parent::getDefinedElements(), [
64
            'source currency' => '#sylius_exchange_rate_sourceCurrency',
65
            'target currency' => '#sylius_exchange_rate_targetCurrency',
66
            'ratio' => '#sylius_exchange_rate_ratio',
67
        ]);
68
    }
69
}
70