Completed
Push — master ( 4c7b9c...e919dc )
by Kamil
21:11
created

PaymentPage::getDefinedElements()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 8
rs 9.4285
c 1
b 0
f 1
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\Shop\Checkout;
13
14
use Behat\Mink\Exception\ElementNotFoundException;
15
use Sylius\Behat\Page\SymfonyPage;
16
17
/**
18
 * @author Anna Walasek <[email protected]>
19
 */
20
class PaymentPage extends SymfonyPage implements PaymentPageInterface
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function getRouteName()
26
    {
27
        return 'sylius_shop_checkout_payment';
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function selectPaymentMethod($paymentMethod)
34
    {
35
        $paymentMethodElement = $this->getElement('payment_method');
36
        $paymentMethodElement->selectOption($paymentMethodElement->getAttribute('value'));
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function hasPaymentMethod($paymentMethodName)
43
    {
44
        try {
45
            $this->getElement('payment_method_option', ['%payment_method%' => $paymentMethodName]);
46
        } catch (ElementNotFoundException $exception) {
47
            return false;
48
        }
49
50
        return true;
51
    }
52
53
    public function nextStep()
54
    {
55
        $this->getDocument()->pressButton('Next');
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    protected function getDefinedElements()
62
    {
63
        return array_merge(parent::getDefinedElements(), [
64
            'order_cannot_be_paid_message' => '#sylius-order-cannot-be-paid',
65
            'payment_method' => '[name="sylius_checkout_payment_step[payments][0][method]"]',
66
            'payment_method_option' => '.item:contains("%payment_method%") input',
67
        ]);
68
    }
69
}
70