Completed
Push — unused-definitions ( d9908f )
by Kamil
18:33
created

CurrencyContext::iShouldNotBeAbleToShop()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
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\Context\Ui\Shop;
13
14
use Behat\Behat\Context\Context;
15
use Sylius\Behat\Page\Shop\HomePageInterface;
16
use Sylius\Behat\Service\SharedStorageInterface;
17
use Sylius\Component\Core\Currency\CurrencyStorageInterface;
18
use Webmozart\Assert\Assert;
19
20
/**
21
 * @author Kamil Kokot <[email protected]>
22
 */
23
final class CurrencyContext implements Context
24
{
25
    /**
26
     * @var HomePageInterface
27
     */
28
    private $homePage;
29
30
    /**
31
     * @var CurrencyStorageInterface
32
     */
33
    private $currencyStorage;
34
35
    /**
36
     * @var SharedStorageInterface
37
     */
38
    private $sharedStorage;
39
40
    /**
41
     * @param HomePageInterface $homePage
42
     */
43
    public function __construct(HomePageInterface $homePage, CurrencyStorageInterface $currencyStorage, SharedStorageInterface $sharedStorage)
44
    {
45
        $this->homePage = $homePage;
46
        $this->currencyStorage = $currencyStorage;
47
        $this->sharedStorage = $sharedStorage;
48
    }
49
50
    /**
51
     * @When I switch to the :currencyCode currency
52
     * @Given I changed my currency to :currencyCode
53
     */
54
    public function iSwitchTheCurrencyToTheCurrency($currencyCode)
55
    {
56
        $this->homePage->open();
57
        $this->homePage->switchCurrency($currencyCode);
58
    }
59
60
    /**
61
     * @Then I should (still) shop using the :currencyCode currency
62
     */
63
    public function iShouldShopUsingTheCurrency($currencyCode)
64
    {
65
        $this->homePage->open();
66
67
        Assert::same($currencyCode, $this->homePage->getActiveCurrency());
68
    }
69
70
    /**
71
     * @Then I should be able to shop using the :currencyCode currency
72
     */
73
    public function iShouldBeAbleToShopUsingTheCurrency($currencyCode)
74
    {
75
        $this->homePage->open();
76
77
        Assert::oneOf($currencyCode, $this->homePage->getAvailableCurrencies());
78
    }
79
80
    /**
81
     * @Then I should not be able to shop using the :currencyCode currency
82
     */
83
    public function iShouldNotBeAbleToShopUsingTheCurrency($currencyCode)
84
    {
85
        $this->homePage->open();
86
87
        if (in_array($currencyCode, $this->homePage->getAvailableCurrencies(), true)) {
88
            throw new \InvalidArgumentException(sprintf(
89
                'Expected "%s" not to be in "%s"',
90
                $currencyCode,
91
                implode('", "', $this->homePage->getAvailableCurrencies())
92
            ));
93
        }
94
    }
95
}
96