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 | * @When I browse exchange rates of the store |
||
76 | */ |
||
77 | public function iWantToBrowseExchangeRatesOfTheStore() |
||
81 | |||
82 | /** |
||
83 | * @When /^I specify its ratio as (-?[0-9\.]+)$/ |
||
84 | * @When I don't specify its ratio |
||
85 | */ |
||
86 | public function iSpecifyItsRatioAs($ratio = null) |
||
90 | |||
91 | /** |
||
92 | * @When I choose :currencyCode as the source currency |
||
93 | */ |
||
94 | public function iChooseAsSourceCurrency($currencyCode) |
||
98 | |||
99 | /** |
||
100 | * @When I choose :currencyCode as the target currency |
||
101 | */ |
||
102 | public function iChooseAsTargetCurrency($currencyCode) |
||
106 | |||
107 | /** |
||
108 | * @When I( try to) add it |
||
109 | */ |
||
110 | public function iAddIt() |
||
114 | |||
115 | /** |
||
116 | * @When I change ratio to :ratio |
||
117 | */ |
||
118 | public function iChangeRatioTo($ratio) |
||
122 | |||
123 | /** |
||
124 | * @When I save my changes |
||
125 | */ |
||
126 | public function iSaveMyChanges() |
||
130 | |||
131 | /** |
||
132 | * @When I delete the exchange rate between :sourceCurrencyName and :targetCurrencyName |
||
133 | */ |
||
134 | public function iDeleteTheExchangeRateBetweenAnd($sourceCurrencyName, $targetCurrencyName) |
||
143 | |||
144 | /** |
||
145 | * @When I choose :currencyName as a currency filter |
||
146 | */ |
||
147 | public function iChooseCurrencyAsACurrencyFilter($currencyName) |
||
151 | |||
152 | /** |
||
153 | * @When I filter |
||
154 | */ |
||
155 | public function iFilter() |
||
159 | |||
160 | /** |
||
161 | * @Then I should see :count exchange rates on the list |
||
162 | */ |
||
163 | public function iShouldSeeExchangeRatesOnTheList($count = 0) |
||
167 | |||
168 | /** |
||
169 | * @Then I should( still) see one exchange rate on the list |
||
170 | */ |
||
171 | public function iShouldSeeOneExchangeRateOnTheList() |
||
177 | |||
178 | /** |
||
179 | * @Then the exchange rate with ratio :ratio between :sourceCurrency and :targetCurrency should appear in the store |
||
180 | */ |
||
181 | public function theExchangeRateBetweenAndShouldAppearInTheStore($ratio, $sourceCurrency, $targetCurrency) |
||
187 | |||
188 | /** |
||
189 | * @Then I should (also) see an exchange rate between :sourceCurrencyName and :targetCurrencyName on the list |
||
190 | */ |
||
191 | public function iShouldSeeAnExchangeRateBetweenAndOnTheList($sourceCurrencyName, $targetCurrencyName) |
||
198 | |||
199 | /** |
||
200 | * @Then it should have a ratio of :ratio |
||
201 | */ |
||
202 | public function thisExchangeRateShouldHaveRatioOf($ratio) |
||
206 | |||
207 | /** |
||
208 | * @Then /^(this exchange rate) should no longer be on the list$/ |
||
209 | */ |
||
210 | public function thisExchangeRateShouldNoLongerBeOnTheList(ExchangeRateInterface $exchangeRate) |
||
217 | |||
218 | /** |
||
219 | * @Then the exchange rate between :sourceCurrencyName and :targetCurrencyName should not be added |
||
220 | */ |
||
221 | public function theExchangeRateBetweenAndShouldNotBeAdded($sourceCurrencyName, $targetCurrencyName) |
||
227 | |||
228 | /** |
||
229 | * @Then /^(this exchange rate) should have a ratio of ([0-9\.]+)$/ |
||
230 | */ |
||
231 | public function thisExchangeRateShouldHaveARatioOf(ExchangeRateInterface $exchangeRate, $ratio) |
||
238 | |||
239 | /** |
||
240 | * @Then I should see that the source currency is disabled |
||
241 | */ |
||
242 | public function iShouldSeeThatTheSourceCurrencyIsDisabled() |
||
246 | |||
247 | /** |
||
248 | * @Then I should see that the target currency is disabled |
||
249 | */ |
||
250 | public function iShouldSeeThatTheTargetCurrencyIsDisabled() |
||
254 | |||
255 | /** |
||
256 | * @Then /^I should be notified that ([^"]+) is required$/ |
||
257 | */ |
||
258 | public function iShouldBeNotifiedThatIsRequired($element) |
||
265 | |||
266 | /** |
||
267 | * @Then I should be notified that the ratio must be greater than zero |
||
268 | */ |
||
269 | public function iShouldBeNotifiedThatRatioMustBeGreaterThanZero() |
||
273 | |||
274 | /** |
||
275 | * @Then I should be notified that source and target currencies must differ |
||
276 | */ |
||
277 | public function iShouldBeNotifiedThatSourceAndTargetCurrenciesMustDiffer() |
||
281 | |||
282 | /** |
||
283 | * @Then I should be notified that the currency pair must be unique |
||
284 | */ |
||
285 | public function iShouldBeNotifiedThatTheCurrencyPairMustBeUnique() |
||
289 | |||
290 | /** |
||
291 | * @param float $ratio |
||
292 | * @param string $sourceCurrencyName |
||
293 | * @param string $targetCurrencyName |
||
294 | * |
||
295 | * @throws \InvalidArgumentException |
||
296 | */ |
||
297 | private function assertExchangeRateWithRatioIsOnTheList($ratio, $sourceCurrencyName, $targetCurrencyName) |
||
313 | |||
314 | /** |
||
315 | * @param string $sourceCurrencyName |
||
316 | * @param string $targetCurrencyName |
||
317 | * |
||
318 | * @throws \InvalidArgumentException |
||
319 | */ |
||
320 | private function assertExchangeRateIsNotOnTheList($sourceCurrencyName, $targetCurrencyName) |
||
334 | |||
335 | /** |
||
336 | * @param int $count |
||
337 | * |
||
338 | * @throws \InvalidArgumentException |
||
339 | */ |
||
340 | private function assertCountOfExchangeRatesOnTheList($count) |
||
348 | |||
349 | /** |
||
350 | * @param string $expectedMessage |
||
351 | * |
||
352 | * @throws \InvalidArgumentException |
||
353 | */ |
||
354 | private function assertFormHasValidationMessage($expectedMessage) |
||
364 | } |
||
365 |