1 | <?php |
||
24 | final class ManagingExchangeRatesContext 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( |
||
55 | |||
56 | /** |
||
57 | * @Given I want to add a new exchange rate |
||
58 | */ |
||
59 | public function iWantToAddNewExchangeRate() |
||
63 | |||
64 | /** |
||
65 | * @Given /^I want to edit (this exchange rate)$/ |
||
66 | * @When /^I am editing (this exchange rate)$/ |
||
67 | */ |
||
68 | public function iWantToEditThisExchangeRate(ExchangeRateInterface $exchangeRate) |
||
72 | |||
73 | /** |
||
74 | * @When I am browsing exchange rates of the store |
||
75 | */ |
||
76 | public function iWantToBrowseExchangeRatesOfTheStore() |
||
80 | |||
81 | /** |
||
82 | * @When /^I specify its ratio as (-?[0-9\.]+)$/ |
||
83 | * @When I don't specify its ratio |
||
84 | */ |
||
85 | public function iSpecifyItsRatioAs($ratio = null) |
||
89 | |||
90 | /** |
||
91 | * @When I choose :currencyCode as the source currency |
||
92 | */ |
||
93 | public function iChooseAsSourceCurrency($currencyCode) |
||
97 | |||
98 | /** |
||
99 | * @When I choose :currencyCode as the target currency |
||
100 | */ |
||
101 | public function iChooseAsTargetCurrency($currencyCode) |
||
105 | |||
106 | /** |
||
107 | * @When I( try to) add it |
||
108 | */ |
||
109 | public function iAddIt() |
||
113 | |||
114 | /** |
||
115 | * @When I change ratio to :ratio |
||
116 | */ |
||
117 | public function iChangeRatioTo($ratio) |
||
121 | |||
122 | /** |
||
123 | * @When I save my changes |
||
124 | */ |
||
125 | public function iSaveMyChanges() |
||
129 | |||
130 | /** |
||
131 | * @When I delete the exchange rate between :sourceCurrencyName and :targetCurrencyName |
||
132 | */ |
||
133 | public function iDeleteTheExchangeRateBetweenAnd($sourceCurrencyName, $targetCurrencyName) |
||
142 | |||
143 | /** |
||
144 | * @Then I should see :count exchange rates on the list |
||
145 | * @Then there should be no exchange rates on the list |
||
146 | */ |
||
147 | public function iShouldSeeExchangeRatesOnTheList($count = 0) |
||
151 | |||
152 | /** |
||
153 | * @Then I should( still) see one exchange rate on the list |
||
154 | */ |
||
155 | public function iShouldSeeOneExchangeRateOnTheList() |
||
161 | |||
162 | /** |
||
163 | * @Then the exchange rate with ratio :ratio between :sourceCurrency and :targetCurrency should appear in the store |
||
164 | */ |
||
165 | public function theExchangeRateBetweenAndShouldAppearInTheStore($ratio, $sourceCurrency, $targetCurrency) |
||
171 | |||
172 | /** |
||
173 | * @Then I should see an exchange rate between :sourceCurrencyName and :targetCurrencyName on the list |
||
174 | */ |
||
175 | public function iShouldSeeAnExchangeRateBetweenAndOnTheList($sourceCurrencyName, $targetCurrencyName) |
||
179 | |||
180 | /** |
||
181 | * @Then it should have a ratio of :ratio |
||
182 | */ |
||
183 | public function thisExchangeRateShouldHaveRatioOf($ratio) |
||
191 | |||
192 | /** |
||
193 | * @Then /^(this exchange rate) should no longer be on the list$/ |
||
194 | */ |
||
195 | public function thisExchangeRateShouldNoLongerBeOnTheList(ExchangeRateInterface $exchangeRate) |
||
202 | |||
203 | /** |
||
204 | * @Then the exchange rate between :sourceCurrencyName and :targetCurrencyName should not be added |
||
205 | * @Then the exchange rate with source currency :sourceCurrencyName should not be added |
||
206 | * @Then the exchange rate with target currency :targetCurrencyName should not be added |
||
207 | */ |
||
208 | public function theExchangeRateBetweenAndShouldNotBeAdded($sourceCurrencyName, $targetCurrencyName) |
||
214 | |||
215 | /** |
||
216 | * @Then /^(this exchange rate) should have a ratio of ([0-9\.]+)$/ |
||
217 | */ |
||
218 | public function thisExchangeRateShouldHaveARatioOf(ExchangeRateInterface $exchangeRate, $ratio) |
||
225 | |||
226 | /** |
||
227 | * @Then I should see that the source currency is disabled |
||
228 | */ |
||
229 | public function iShouldSeeThatTheSourceCurrencyIsDisabled() |
||
236 | |||
237 | /** |
||
238 | * @Then I should see that the target currency is disabled |
||
239 | */ |
||
240 | public function iShouldSeeThatTheTargetCurrencyIsDisabled() |
||
247 | |||
248 | /** |
||
249 | * @Then /^I should be notified that ([^"]+) is required$/ |
||
250 | */ |
||
251 | public function iShouldBeNotifiedThatIsRequired($element) |
||
258 | |||
259 | /** |
||
260 | * @Then I should be notified that the ratio must be greater than zero |
||
261 | */ |
||
262 | public function iShouldBeNotifiedThatRatioMustBeGreaterThanZero() |
||
266 | |||
267 | /** |
||
268 | * @Then I should be notified that source and target currencies must differ |
||
269 | */ |
||
270 | public function iShouldBeNotifiedThatSourceAndTargetCurrenciesMustDiffer() |
||
276 | |||
277 | /** |
||
278 | * @Then I should be notified that the currency pair must be unique |
||
279 | */ |
||
280 | public function iShouldBeNotifiedThatTheCurrencyPairMustBeUnique() |
||
286 | |||
287 | /** |
||
288 | * @param string $sourceCurrencyName |
||
289 | * @param string $targetCurrencyName |
||
290 | * |
||
291 | * @throws \InvalidArgumentException |
||
292 | */ |
||
293 | private function assertExchangeRateIsOnList($sourceCurrencyName, $targetCurrencyName) |
||
307 | |||
308 | /** |
||
309 | * @param float $ratio |
||
310 | * @param string $sourceCurrencyName |
||
311 | * @param string $targetCurrencyName |
||
312 | * |
||
313 | * @throws \InvalidArgumentException |
||
314 | */ |
||
315 | private function assertExchangeRateWithRatioIsOnTheList($ratio, $sourceCurrencyName, $targetCurrencyName) |
||
331 | |||
332 | /** |
||
333 | * @param string $sourceCurrencyName |
||
334 | * @param string $targetCurrencyName |
||
335 | * |
||
336 | * @throws \InvalidArgumentException |
||
337 | */ |
||
338 | private function assertExchangeRateIsNotOnTheList($sourceCurrencyName, $targetCurrencyName) |
||
352 | |||
353 | /** |
||
354 | * @param int $count |
||
355 | * |
||
356 | * @throws \InvalidArgumentException |
||
357 | */ |
||
358 | private function assertCountOfExchangeRatesOnTheList($count) |
||
368 | |||
369 | /** |
||
370 | * @param string $expectedMessage |
||
371 | * |
||
372 | * @throws \InvalidArgumentException |
||
373 | */ |
||
374 | private function assertFormHasValidationMessage($expectedMessage) |
||
384 | } |
||
385 |