Completed
Push — master ( 6f962e...f87bab )
by Paweł
15s
created

iShouldBeNotifiedAboutSuccessfulCreation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
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\Admin;
13
14
use Behat\Behat\Context\Context;
15
use Sylius\Behat\Page\Admin\Locale\CreatePageInterface;
16
use Sylius\Behat\Page\Admin\Locale\IndexPageInterface;
17
use Sylius\Behat\Page\Admin\Locale\UpdatePageInterface;
18
use Sylius\Component\Locale\Model\LocaleInterface;
19
use Webmozart\Assert\Assert;
20
21
/**
22
 * @author Łukasz Chruściel <[email protected]>
23
 */
24
final class ManagingLocalesContext implements Context
25
{
26
    /**
27
     * @var CreatePageInterface
28
     */
29
    private $createPage;
30
31
    /**
32
     * @var IndexPageInterface
33
     */
34
    private $indexPage;
35
36
    /**
37
     * @var UpdatePageInterface
38
     */
39
    private $updatePage;
40
41
    /**
42
     * @param CreatePageInterface $createPage
43
     * @param IndexPageInterface $indexPage
44
     * @param UpdatePageInterface $updatePage
45
     */
46
    public function __construct(
47
        CreatePageInterface $createPage,
48
        IndexPageInterface $indexPage,
49
        UpdatePageInterface $updatePage
50
    ) {
51
        $this->createPage = $createPage;
52
        $this->indexPage = $indexPage;
53
        $this->updatePage = $updatePage;
54
    }
55
56
    /**
57
     * @Given I want to create a new locale
58
     * @Given I want to add a new locale
59
     */
60
    public function iWantToCreateNewLocale()
61
    {
62
        $this->createPage->open();
63
    }
64
65
    /**
66
     * @Given /^I want to edit (this locale)$/
67
     */
68
    public function iWantToEditThisLocale(LocaleInterface $locale)
69
    {
70
        $this->updatePage->open(['id' => $locale->getId()]);
71
    }
72
73
    /**
74
     * @When I choose :name
75
     */
76
    public function iChoose($name)
77
    {
78
        $this->createPage->chooseName($name);
79
    }
80
81
    /**
82
     * @When I add it
83
     */
84
    public function iAdd()
85
    {
86
        $this->createPage->create();
87
    }
88
89
    /**
90
     * @When I enable it
91
     */
92
    public function iEnableIt()
93
    {
94
        $this->updatePage->enable();
95
    }
96
97
    /**
98
     * @When I disable it
99
     */
100
    public function iDisableIt()
101
    {
102
        $this->updatePage->disable();
103
    }
104
105
    /**
106
     * @When I save my changes
107
     */
108
    public function iSaveMyChanges()
109
    {
110
        $this->updatePage->saveChanges();
111
    }
112
113
    /**
114
     * @Then the store should be available in the :name language
115
     */
116
    public function storeShouldBeAvailableInLanguage($name)
117
    {
118
        $doesLocaleExist = $this->indexPage->isSingleResourceOnPage(['name' => $name]);
119
        Assert::true(
120
            $doesLocaleExist,
121
            sprintf('Locale %s should exist but it does not', $name)
122
        );
123
    }
124
125
    /**
126
     * @Then /^(this locale) should be enabled$/
127
     */
128
    public function thisLocaleShouldBeEnabled(LocaleInterface $locale)
129
    {
130
        Assert::true(
131
            $this->indexPage->isLocaleEnabled($locale),
132
            sprintf('Locale %s should be enabled but it is not', $locale->getCode())
133
        );
134
    }
135
136
    /**
137
     * @Then /^(this locale) should be disabled$/
138
     */
139
    public function thisLocaleShouldBeDisabled(LocaleInterface $locale)
140
    {
141
        Assert::true(
142
            $this->indexPage->isLocaleDisabled($locale),
143
            sprintf('Locale %s should be disabled but it is not', $locale->getCode())
144
        );
145
    }
146
147
    /**
148
     * @Then I should not be able to choose :name
149
     */
150
    public function iShouldNotBeAbleToChoose($name)
151
    {
152
        Assert::false(
153
            $this->createPage->isOptionAvailable($name),
154
            sprintf('I can choose %s, but i should not be able to do it', $name)
155
        );
156
    }
157
}
158