1 | <?php |
||
14 | class FixtureContext extends BaseFixtureContext |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * Select a gallery item by type and name |
||
19 | * |
||
20 | * @Given /^I (?:(?:click on)|(?:select)) the file named "([^"]+)" in the gallery$/ |
||
21 | * @param string $name |
||
22 | */ |
||
23 | public function stepISelectGalleryItem($name) |
||
29 | |||
30 | /** |
||
31 | * Check the checkbox for a given gallery item |
||
32 | * @Given /^I check the file named "([^"]+)" in the gallery$/ |
||
33 | * @param string $name |
||
34 | */ |
||
35 | public function stepICheckTheGalleryItem($name) |
||
43 | |||
44 | /** |
||
45 | * @Then /^I should see the file named "([^"]+)" in the gallery$/ |
||
46 | * @param string $name |
||
47 | */ |
||
48 | public function iShouldSeeTheGalleryItem($name) |
||
53 | |||
54 | /** |
||
55 | * @Then /^I should not see the file named "([^"]+)" in the gallery$/ |
||
56 | * @param string $name |
||
57 | */ |
||
58 | public function iShouldNotSeeTheGalleryItem($name) |
||
63 | |||
64 | /** |
||
65 | * @Then /^I should see the "([^"]*)" form$/ |
||
66 | * @param string $id HTML ID of form |
||
67 | */ |
||
68 | public function iShouldSeeTheForm($id) |
||
78 | |||
79 | /** |
||
80 | * @Then /^I should see the draft file status flag$/ |
||
81 | */ |
||
82 | public function iShouldSeeTheDraftFileStatusFlag() |
||
89 | |||
90 | /** |
||
91 | * @Then /^I should not see the file status flag$/ |
||
92 | */ |
||
93 | public function iShouldNotSeeTheFileStatusFlag() |
||
99 | |||
100 | /** |
||
101 | * @Given /^I click on the latest history item$/ |
||
102 | */ |
||
103 | public function iClickOnTheLatestHistoryItem() |
||
120 | |||
121 | /** |
||
122 | * @Given /^I attach the file "([^"]*)" to dropzone "([^"]*)"$/ |
||
123 | * @see MinkContext::attachFileToField() |
||
124 | */ |
||
125 | public function iAttachTheFileToDropzone($path, $name) |
||
159 | |||
160 | /** |
||
161 | * Checks that the message box contains specified text. |
||
162 | * |
||
163 | * @Then /^I should see "(?P<text>(?:[^"]|\\")*)" in the message box$/ |
||
164 | */ |
||
165 | public function assertMessageBoxContainsText($text) |
||
173 | |||
174 | /** |
||
175 | * Helper for finding items in the visible gallery view |
||
176 | * |
||
177 | * @param string $name Title of item |
||
178 | * @param int $timeout |
||
179 | * @return NodeElement |
||
180 | */ |
||
181 | protected function getGalleryItem($name, $timeout = 3) |
||
205 | |||
206 | /** |
||
207 | * Invoke $try callback for a non-empty result with a given timeout |
||
208 | * |
||
209 | * @param callable $try |
||
210 | * @param int $timeout Number of seconds to retry for |
||
211 | * @return mixed Result of invoking $try, or null if timed out |
||
212 | */ |
||
213 | protected function retry($try, $timeout = 3) |
||
224 | |||
225 | /** |
||
226 | * @Given /^a page "([^"]*)" containing an image "([^"]*)"$/ |
||
227 | */ |
||
228 | public function aPageContaining($page, $image) |
||
248 | } |
||
249 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: