1 | <?php |
||
24 | final class ManagingExchangeRatesContext implements Context |
||
25 | { |
||
26 | /** @var CreatePageInterface */ |
||
27 | private $createPage; |
||
28 | |||
29 | /** @var IndexPageInterface */ |
||
30 | private $indexPage; |
||
31 | |||
32 | /** @var UpdatePageInterface */ |
||
33 | private $updatePage; |
||
34 | |||
35 | public function __construct( |
||
44 | |||
45 | /** |
||
46 | * @Given I want to add a new exchange rate |
||
47 | */ |
||
48 | public function iWantToAddNewExchangeRate() |
||
52 | |||
53 | /** |
||
54 | * @Given /^I want to edit (this exchange rate)$/ |
||
55 | * @When /^I am editing (this exchange rate)$/ |
||
56 | */ |
||
57 | public function iWantToEditThisExchangeRate(ExchangeRateInterface $exchangeRate) |
||
61 | |||
62 | /** |
||
63 | * @Given I am browsing exchange rates of the store |
||
64 | * @When I browse exchange rates |
||
65 | * @When I browse exchange rates of the store |
||
66 | */ |
||
67 | public function iWantToBrowseExchangeRatesOfTheStore() |
||
71 | |||
72 | /** |
||
73 | * @When /^I specify its ratio as (-?[0-9\.]+)$/ |
||
74 | * @When I don't specify its ratio |
||
75 | */ |
||
76 | public function iSpecifyItsRatioAs($ratio = null) |
||
80 | |||
81 | /** |
||
82 | * @When I choose :currencyCode as the source currency |
||
83 | */ |
||
84 | public function iChooseAsSourceCurrency($currencyCode) |
||
88 | |||
89 | /** |
||
90 | * @When I choose :currencyCode as the target currency |
||
91 | */ |
||
92 | public function iChooseAsTargetCurrency($currencyCode) |
||
96 | |||
97 | /** |
||
98 | * @When I( try to) add it |
||
99 | */ |
||
100 | public function iAddIt() |
||
104 | |||
105 | /** |
||
106 | * @When I change ratio to :ratio |
||
107 | */ |
||
108 | public function iChangeRatioTo($ratio) |
||
112 | |||
113 | /** |
||
114 | * @When I save my changes |
||
115 | */ |
||
116 | public function iSaveMyChanges() |
||
120 | |||
121 | /** |
||
122 | * @When I delete the exchange rate between :sourceCurrencyName and :targetCurrencyName |
||
123 | */ |
||
124 | public function iDeleteTheExchangeRateBetweenAnd($sourceCurrencyName, $targetCurrencyName) |
||
133 | |||
134 | /** |
||
135 | * @When I choose :currencyName as a currency filter |
||
136 | */ |
||
137 | public function iChooseCurrencyAsACurrencyFilter($currencyName) |
||
141 | |||
142 | /** |
||
143 | * @When I filter |
||
144 | */ |
||
145 | public function iFilter() |
||
149 | |||
150 | /** |
||
151 | * @When I check (also) the exchange rate between :sourceCurrencyName and :targetCurrencyName |
||
152 | */ |
||
153 | public function iCheckTheExchangeRateBetweenAnd(string $sourceCurrencyName, string $targetCurrencyName): void |
||
160 | |||
161 | /** |
||
162 | * @When I delete them |
||
163 | */ |
||
164 | public function iDeleteThem(): void |
||
168 | |||
169 | /** |
||
170 | * @Then I should see :count exchange rates on the list |
||
171 | */ |
||
172 | public function iShouldSeeExchangeRatesOnTheList($count = 0) |
||
176 | |||
177 | /** |
||
178 | * @Then I should see a single exchange rate in the list |
||
179 | * @Then I should( still) see one exchange rate on the list |
||
180 | */ |
||
181 | public function iShouldSeeOneExchangeRateOnTheList() |
||
187 | |||
188 | /** |
||
189 | * @Then the exchange rate with ratio :ratio between :sourceCurrency and :targetCurrency should appear in the store |
||
190 | */ |
||
191 | public function theExchangeRateBetweenAndShouldAppearInTheStore($ratio, CurrencyInterface $sourceCurrency, CurrencyInterface $targetCurrency) |
||
197 | |||
198 | /** |
||
199 | * @Then I should see the exchange rate between :sourceCurrencyName and :targetCurrencyName in the list |
||
200 | * @Then I should (also) see an exchange rate between :sourceCurrencyName and :targetCurrencyName on the list |
||
201 | */ |
||
202 | public function iShouldSeeAnExchangeRateBetweenAndOnTheList( |
||
211 | |||
212 | /** |
||
213 | * @Then it should have a ratio of :ratio |
||
214 | */ |
||
215 | public function thisExchangeRateShouldHaveRatioOf($ratio) |
||
219 | |||
220 | /** |
||
221 | * @Then /^(this exchange rate) should no longer be on the list$/ |
||
222 | */ |
||
223 | public function thisExchangeRateShouldNoLongerBeOnTheList(ExchangeRateInterface $exchangeRate) |
||
230 | |||
231 | /** |
||
232 | * @Then the exchange rate between :sourceCurrencyName and :targetCurrencyName should not be added |
||
233 | */ |
||
234 | public function theExchangeRateBetweenAndShouldNotBeAdded($sourceCurrencyName, $targetCurrencyName) |
||
240 | |||
241 | /** |
||
242 | * @Then /^(this exchange rate) should have a ratio of ([0-9\.]+)$/ |
||
243 | */ |
||
244 | public function thisExchangeRateShouldHaveARatioOf(ExchangeRateInterface $exchangeRate, $ratio) |
||
251 | |||
252 | /** |
||
253 | * @Then I should not be able to edit its source currency |
||
254 | */ |
||
255 | public function iShouldNotBeAbleToEditItsSourceCurrency(): void |
||
256 | { |
||
257 | Assert::true($this->updatePage->isSourceCurrencyDisabled()); |
||
258 | } |
||
259 | |||
260 | /** |
||
261 | * @Then I should not be able to edit its target currency |
||
262 | */ |
||
263 | public function iShouldNotBeAbleToEditItsTargetCurrency(): void |
||
264 | { |
||
265 | Assert::true($this->updatePage->isTargetCurrencyDisabled()); |
||
266 | } |
||
267 | |||
268 | /** |
||
269 | * @Then /^I should be notified that ([^"]+) is required$/ |
||
270 | */ |
||
271 | public function iShouldBeNotifiedThatIsRequired($element) |
||
278 | |||
279 | /** |
||
280 | * @Then I should be notified that the ratio must be greater than zero |
||
281 | */ |
||
282 | public function iShouldBeNotifiedThatRatioMustBeGreaterThanZero() |
||
286 | |||
287 | /** |
||
288 | * @Then I should be notified that source and target currencies must differ |
||
289 | */ |
||
290 | public function iShouldBeNotifiedThatSourceAndTargetCurrenciesMustDiffer() |
||
294 | |||
295 | /** |
||
296 | * @Then I should be notified that the currency pair must be unique |
||
297 | */ |
||
298 | public function iShouldBeNotifiedThatTheCurrencyPairMustBeUnique() |
||
302 | |||
303 | /** |
||
304 | * @param float $ratio |
||
305 | * @param string $sourceCurrencyName |
||
306 | * @param string $targetCurrencyName |
||
307 | * |
||
308 | * @throws \InvalidArgumentException |
||
309 | */ |
||
310 | private function assertExchangeRateWithRatioIsOnTheList($ratio, $sourceCurrencyName, $targetCurrencyName) |
||
326 | |||
327 | /** |
||
328 | * @param string $sourceCurrencyName |
||
329 | * @param string $targetCurrencyName |
||
330 | * |
||
331 | * @throws \InvalidArgumentException |
||
332 | */ |
||
333 | private function assertExchangeRateIsNotOnTheList($sourceCurrencyName, $targetCurrencyName) |
||
347 | |||
348 | /** |
||
349 | * @param int $count |
||
350 | * |
||
351 | * @throws \InvalidArgumentException |
||
352 | */ |
||
353 | private function assertCountOfExchangeRatesOnTheList($count) |
||
361 | |||
362 | /** |
||
363 | * @param string $expectedMessage |
||
364 | * |
||
365 | * @throws \InvalidArgumentException |
||
366 | */ |
||
367 | private function assertFormHasValidationMessage($expectedMessage) |
||
377 | } |
||
378 |