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

CreatePage::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\SpecifiesItsCode;
16
use Sylius\Behat\Behaviour\Toggles;
17
use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage;
18
19
/**
20
 * @author Grzegorz Sadowski <[email protected]>
21
 */
22
class CreatePage extends BaseCreatePage implements CreatePageInterface
23
{
24
    use ChecksCodeImmutability;
25
    use Toggles;
26
    use SpecifiesItsCode;
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function nameIt($name, $languageCode)
32
    {
33
        $this->getDocument()->fillField(
34
            sprintf('sylius_payment_method_translations_%s_name', $languageCode), $name
35
        );
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function checkChannel($channelName)
42
    {
43
        $this->getDocument()->checkField($channelName);
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function describeIt($description, $languageCode)
50
    {
51
        $this->getDocument()->fillField(
52
            sprintf('sylius_payment_method_translations_%s_description', $languageCode), $description
53
        );
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function setInstructions($instructions, $languageCode)
60
    {
61
        $this->getDocument()->fillField(
62
            sprintf('sylius_payment_method_translations_%s_instructions', $languageCode), $instructions
63
        );
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69
    public function setPaypalGatewayUsername($username)
70
    {
71
        $this->getDocument()->fillField('Username', $username);
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77
    public function setPaypalGatewayPassword($password)
78
    {
79
        $this->getDocument()->fillField('Password', $password);
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85
    public function setPaypalGatewaySignature($signature)
86
    {
87
        $this->getDocument()->fillField('Signature', $signature);
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93
    public function setStripeSecretKey($secretKey)
94
    {
95
        $this->getDocument()->fillField('Secret key', $secretKey);
96
    }
97
98
    /**
99
     * {@inheritdoc}
100
     */
101
    public function setStripePublishableKey($publishableKey)
102
    {
103
        $this->getDocument()->fillField('Publishable key', $publishableKey);
104
    }
105
106
    /**
107
     * {@inheritdoc}
108
     */
109
    public function isPaymentMethodEnabled()
110
    {
111
        return (bool) $this->getToggleableElement()->getValue();
112
    }
113
114
    /**
115
     * {@inheritdoc}
116
     */
117
    protected function getCodeElement()
118
    {
119
        return $this->getElement('code');
120
    }
121
122
    /**
123
     * {@inheritdoc}
124
     */
125
    protected function getToggleableElement()
126
    {
127
        return $this->getElement('enabled');
128
    }
129
130
    /**
131
     * {@inheritdoc}
132
     */
133
    protected function getDefinedElements()
134
    {
135
        return array_merge(parent::getDefinedElements(), [
136
            'code' => '#sylius_payment_method_code',
137
            'enabled' => '#sylius_payment_method_enabled',
138
            'gateway_name' => '#sylius_payment_method_gatewayConfig_gatewayName',
139
            'name' => '#sylius_payment_method_translations_en_US_name',
140
            'paypal_password' => '#sylius_payment_method_gatewayConfig_config_password',
141
        ]);
142
    }
143
}
144