Completed
Push — master ( a9aa0c...602f1d )
by Kamil
26:22 queued 09:35
created

iGoToTheChangePaymentMethodPage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
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
declare(strict_types=1);
13
14
namespace Sylius\Behat\Context\Ui\Shop\Checkout;
15
16
use Behat\Behat\Context\Context;
17
use Sylius\Behat\Page\Shop\Account\Order\ShowPageInterface;
18
use Sylius\Behat\Page\Shop\Order\ThankYouPageInterface;
19
use Sylius\Component\Core\Model\PaymentMethodInterface;
20
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
21
use Webmozart\Assert\Assert;
22
23
final class CheckoutThankYouContext implements Context
24
{
25
    /** @var ThankYouPageInterface */
26
    private $thankYouPage;
27
28
    /** @var ShowPageInterface */
29
    private $orderShowPage;
30
31
    /** @var OrderRepositoryInterface */
32
    private $orderRepository;
33
34
    public function __construct(
35
        ThankYouPageInterface $thankYouPage,
36
        ShowPageInterface $orderShowPage,
37
        OrderRepositoryInterface $orderRepository
38
    ) {
39
        $this->thankYouPage = $thankYouPage;
40
        $this->orderShowPage = $orderShowPage;
41
        $this->orderRepository = $orderRepository;
42
    }
43
44
    /**
45
     * @When I go to the change payment method page
46
     */
47
    public function iGoToTheChangePaymentMethodPage(): void
48
    {
49
        $this->thankYouPage->goToTheChangePaymentMethodPage();
50
    }
51
52
    /**
53
     * @When I proceed to the registration
54
     */
55
    public function iProceedToTheRegistration(): void
56
    {
57
        $this->thankYouPage->createAccount();
58
    }
59
60
    /**
61
     * @Then I should be able to access this order's details
62
     */
63
    public function iShouldBeAbleToAccessThisOrderDetails(): void
64
    {
65
        $this->thankYouPage->goToOrderDetailsInAccount();
66
67
        $number = $this->orderShowPage->getNumber();
68
69
        Assert::same($this->orderRepository->findLatest(1)[0]->getNumber(), $number);
70
    }
71
72
    /**
73
     * @Then I should see the thank you page
74
     */
75
    public function iShouldSeeTheThankYouPage()
76
    {
77
        Assert::true($this->thankYouPage->hasThankYouMessage());
78
    }
79
80
    /**
81
     * @Then I should see the thank you page in :localeCode
82
     */
83
    public function iShouldSeeTheThankYouPageInLocale($localeCode)
84
    {
85
        Assert::false($this->thankYouPage->isOpen(['_locale' => $localeCode]));
86
    }
87
88
    /**
89
     * @Then I should not see the thank you page
90
     */
91
    public function iShouldNotSeeTheThankYouPage()
92
    {
93
        Assert::false($this->thankYouPage->isOpen());
94
    }
95
96
    /**
97
     * @Then I should be informed with :paymentMethod payment method instructions
98
     */
99
    public function iShouldBeInformedWithPaymentMethodInstructions(PaymentMethodInterface $paymentMethod)
100
    {
101
        Assert::same($this->thankYouPage->getInstructions(), $paymentMethod->getInstructions());
102
    }
103
104
    /**
105
     * @Then I should not see any instructions about payment method
106
     */
107
    public function iShouldNotSeeAnyInstructionsAboutPaymentMethod()
108
    {
109
        Assert::false($this->thankYouPage->hasInstructions());
110
    }
111
112
    /**
113
     * @Then I should not be able to change payment method
114
     */
115
    public function iShouldNotBeAbleToChangeMyPaymentMethod()
116
    {
117
        Assert::false($this->thankYouPage->hasChangePaymentMethodButton());
118
    }
119
120
    /**
121
     * @Then I should be able to proceed to the registration
122
     */
123
    public function iShouldBeAbleToProceedToTheRegistration(): void
124
    {
125
        Assert::true($this->thankYouPage->hasRegistrationButton());
126
    }
127
128
    /**
129
     * @Then I should not be able to proceed to the registration
130
     */
131
    public function iShouldNotBeAbleToProceedToTheRegistration(): void
132
    {
133
        Assert::false($this->thankYouPage->hasRegistrationButton());
134
    }
135
}
136