Completed
Push — master ( bfd93b...a37554 )
by Kamil
15s
created

UpdatePage::chooseGateway()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
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
namespace Sylius\Behat\Page\Admin\PaymentMethod;
13
14
use Sylius\Behat\Behaviour\ChecksCodeImmutability;
15
use Sylius\Behat\Behaviour\Toggles;
16
use Sylius\Behat\Page\Admin\Crud\UpdatePage as BaseUpdatePage;
17
18
/**
19
 * @author Arkadiusz Krakowiak <[email protected]>
20
 */
21
class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
22
{
23
    use ChecksCodeImmutability;
24
    use Toggles;
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function setPaypalGatewayUsername($username)
30
    {
31
        $this->getDocument()->fillField('Username', $username);
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function setPaypalGatewayPassword($password)
38
    {
39
        $this->getDocument()->fillField('Password', $password);
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function setPaypalGatewaySignature($signature)
46
    {
47
        $this->getDocument()->fillField('Signature', $signature);
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function nameIt($name, $languageCode)
54
    {
55
        $this->getDocument()->fillField(sprintf('sylius_payment_method_translations_%s_name', $languageCode), $name);
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function isPaymentMethodEnabled()
62
    {
63
        return (bool) $this->getToggleableElement()->getValue();
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69
    public function isFactoryNameFieldDisabled()
70
    {
71
        return 'disabled' === $this->getElement('factory_name')->getAttribute('disabled');
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77
    public function isAvailableInChannel($channelName)
78
    {
79
        return $this->getElement('channel', ['%channel%' => $channelName])->hasAttribute('checked');
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85
    public function getPaymentMethodInstructions($language)
86
    {
87
        return $this->getElement('instructions', ['%language%' => $language])->getText();
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93
    protected function getCodeElement()
94
    {
95
        return $this->getElement('code');
96
    }
97
98
    /**
99
     * {@inheritdoc}
100
     */
101
    protected function getToggleableElement()
102
    {
103
        return $this->getElement('enabled');
104
    }
105
106
    /**
107
     * {@inheritdoc}
108
     */
109
    protected function getDefinedElements()
110
    {
111
        return array_merge(parent::getDefinedElements(), [
112
            'channel' => '.checkbox:contains("%channel%") input',
113
            'code' => '#sylius_payment_method_code',
114
            'enabled' => '#sylius_payment_method_enabled',
115
            'factory_name' => '#sylius_payment_method_gatewayConfig_factoryName',
116
            'instructions' => '#sylius_payment_method_translations_%language%_instructions',
117
            'name' => '#sylius_payment_method_translations_en_US_name',
118
        ]);
119
    }
120
}
121