1 | <?php |
||
26 | final class ManagingCurrenciesContext implements Context |
||
27 | { |
||
28 | const RESOURCE_NAME = 'currency'; |
||
29 | |||
30 | /** |
||
31 | * @var IndexPageInterface |
||
32 | */ |
||
33 | private $indexPage; |
||
34 | |||
35 | /** |
||
36 | * @var CreatePageInterface |
||
37 | */ |
||
38 | private $createPage; |
||
39 | |||
40 | /** |
||
41 | * @var UpdatePageInterface |
||
42 | */ |
||
43 | private $updatePage; |
||
44 | |||
45 | /** |
||
46 | * @var NotificationCheckerInterface |
||
47 | */ |
||
48 | private $notificationChecker; |
||
49 | |||
50 | /** |
||
51 | * @var CurrentPageResolverInterface |
||
52 | */ |
||
53 | private $currentPageResolver; |
||
54 | |||
55 | /** |
||
56 | * @param IndexPageInterface $indexPage |
||
57 | * @param CreatePageInterface $createPage |
||
58 | * @param UpdatePageInterface $updatePage |
||
59 | * @param CurrentPageResolverInterface $currentPageResolver |
||
60 | * @param NotificationCheckerInterface $notificationChecker |
||
61 | */ |
||
62 | public function __construct( |
||
75 | |||
76 | /** |
||
77 | * @Given I want to add a new currency |
||
78 | */ |
||
79 | public function iWantToAddNewCurrency() |
||
83 | |||
84 | /** |
||
85 | * @When I choose :currencyName |
||
86 | */ |
||
87 | public function iChoose($currencyName) |
||
91 | |||
92 | /** |
||
93 | * @When I add it |
||
94 | * @When I try to add it |
||
95 | */ |
||
96 | public function iAddIt() |
||
100 | |||
101 | /** |
||
102 | * @Then I should be notified that it has been successfully created |
||
103 | */ |
||
104 | public function iShouldBeNotifiedThatItHasBeenSuccessfullyCreated() |
||
105 | { |
||
106 | $this->notificationChecker->checkCreationNotification(self::RESOURCE_NAME); |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * @When I specify its exchange rate as :exchangeRate |
||
111 | */ |
||
112 | public function iSpecifyExchangeRate($exchangeRate) |
||
113 | { |
||
114 | $this->createPage->specifyExchangeRate($exchangeRate); |
||
115 | } |
||
116 | |||
117 | /** |
||
118 | * @Then the currency :currency should appear in the store |
||
119 | * @Then I should see the currency :currency in the list |
||
120 | */ |
||
121 | public function currencyShouldAppearInTheStore(CurrencyInterface $currency) |
||
130 | |||
131 | /** |
||
132 | * @Given /^I want to edit (this currency)$/ |
||
133 | */ |
||
134 | public function iWantToEditThisCurrency(CurrencyInterface $currency) |
||
138 | |||
139 | /** |
||
140 | * @When I enable it |
||
141 | */ |
||
142 | public function iEnableIt() |
||
146 | |||
147 | /** |
||
148 | * @When I disable it |
||
149 | */ |
||
150 | public function iDisableIt() |
||
154 | |||
155 | /** |
||
156 | * @When I save my changes |
||
157 | * @When I try to save my changes |
||
158 | */ |
||
159 | public function iSaveMyChanges() |
||
163 | |||
164 | /** |
||
165 | * @Then I should be notified that it has been successfully edited |
||
166 | */ |
||
167 | public function iShouldBeNotifiedThatItHasBeenSuccessfullyEdited() |
||
168 | { |
||
169 | $this->notificationChecker->checkEditionNotification(self::RESOURCE_NAME); |
||
170 | } |
||
171 | |||
172 | /** |
||
173 | * @Then /^(this currency) should be disabled$/ |
||
174 | */ |
||
175 | public function thisCurrencyShouldBeDisabled(CurrencyInterface $currency) |
||
184 | |||
185 | /** |
||
186 | * @Then /^(this currency) should be enabled$/ |
||
187 | */ |
||
188 | public function thisCurrencyShouldBeEnabled(CurrencyInterface $currency) |
||
197 | |||
198 | /** |
||
199 | * @When I change exchange rate to :exchangeRate |
||
200 | */ |
||
201 | public function iChangeExchangeRateTo($exchangeRate) |
||
205 | |||
206 | /** |
||
207 | * @Then this currency should have exchange rate :exchangeRate |
||
208 | */ |
||
209 | public function thisCurrencyShouldHaveExchangeRate($exchangeRate) |
||
221 | |||
222 | /** |
||
223 | * @Then the code field should be disabled |
||
224 | */ |
||
225 | public function theCodeFiledShouldBeDisabled() |
||
233 | |||
234 | /** |
||
235 | * @Then I should be notified that currency code must be unique |
||
236 | */ |
||
237 | public function iShouldBeNotifiedThatCurrencyCodeMustBeUnique() |
||
244 | |||
245 | /** |
||
246 | * @Then there should still be only one currency with :element :code |
||
247 | */ |
||
248 | public function thereShouldStillBeOnlyOneCurrencyWithCode($element, $codeValue) |
||
257 | |||
258 | /** |
||
259 | * @Then I should be notified that exchange rate is required |
||
260 | */ |
||
261 | public function iShouldBeNotifiedThatExchangeRateIsRequired() |
||
270 | |||
271 | /** |
||
272 | * @Then the currency :currencyName should not be added |
||
273 | */ |
||
274 | public function theCurrencyShouldNotBeAdded($currencyName) |
||
283 | |||
284 | /** |
||
285 | * @When I remove its exchange rate |
||
286 | */ |
||
287 | public function iRemoveItsExchangeRate() |
||
291 | |||
292 | /** |
||
293 | * @Then /^(this currency) should still have exchange rate equal to ((\d+)\.(\d+))$/ |
||
294 | */ |
||
295 | public function theCurrencyShouldStillHaveExchangeRateEquals(CurrencyInterface $currency, $exchangeRate) |
||
309 | |||
310 | /** |
||
311 | * @Given I browse currencies of the store |
||
312 | */ |
||
313 | public function iWantToSeeAllCurrenciesInStore() |
||
317 | |||
318 | /** |
||
319 | * @Then /^I should see (\d+) currencies in the list$/ |
||
320 | */ |
||
321 | public function iShouldSeeCurrenciesInTheList($amountOfCurrencies) |
||
333 | } |
||
334 |