Completed
Push — symfony-fqcn-sylius-4 ( 896d93...f41f61 )
by Kamil
18:34
created

ShowPage::getNotifications()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
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\Order;
13
14
use Behat\Mink\Element\NodeElement;
15
use Sylius\Behat\Page\SymfonyPage;
16
17
/**
18
 * @author Arkadiusz Krakowiak <[email protected]>
19
 */
20
final class ShowPage extends SymfonyPage implements ShowPageInterface
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function hasPayAction()
26
    {
27
        return $this->hasElement('pay_link');
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function pay()
34
    {
35
        $this->getElement('pay_link')->click();
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function getNotifications()
42
    {
43
        /** @var NodeElement[] $notificationElements */
44
        $notificationElements = $this->getDocument()->findAll('css', '.message > .content > p');
45
        $notifications = [];
46
47
        foreach ($notificationElements as $notificationElement) {
48
            $notifications[] = $notificationElement->getText();
49
        }
50
51
        return $notifications;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function choosePaymentMethod($paymentMethodName)
58
    {
59
        $paymentMethodElement = $this->getElement('payment_method', ['%name%' => $paymentMethodName]);
60
        $paymentMethodElement->selectOption($paymentMethodElement->getAttribute('value'));
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function getRouteName()
67
    {
68
        return 'sylius_shop_order_show';
69
    }
70
71
    /**
72
     * {@inheritdoc}
73
     */
74
    protected function getDefinedElements()
75
    {
76
        return array_merge(parent::getDefinedElements(), [
77
            'instructions' => '#sylius-payment-method-instructions',
78
            'pay_link' => '#sylius-pay-link',
79
            'payment_method' => '.item:contains("%name%") input',
80
            'thank_you' => '#sylius-thank-you',
81
        ]);
82
    }
83
}
84