1 | <?php |
||
24 | class CoreContext extends RawMinkContext |
||
25 | { |
||
26 | static protected $application; |
||
27 | |||
28 | /** |
||
29 | * @var MinkContext |
||
30 | */ |
||
31 | protected $minkContext; |
||
32 | |||
33 | static private $jobCategoryChecked = false; |
||
34 | |||
35 | /** |
||
36 | * @BeforeScenario |
||
37 | * @param BeforeScenarioScope $scope |
||
38 | */ |
||
39 | public function gatherContexts(BeforeScenarioScope $scope) |
||
54 | |||
55 | /** |
||
56 | * @return Application |
||
57 | */ |
||
58 | public function getApplication() |
||
67 | |||
68 | /** |
||
69 | * @return \Zend\ServiceManager\ServiceManager |
||
70 | */ |
||
71 | public function getServiceManager() |
||
75 | |||
76 | /** |
||
77 | * @return \Zend\EventManager\EventManagerInterface |
||
78 | */ |
||
79 | public function getEventManager() |
||
83 | |||
84 | /** |
||
85 | * @return RepositoryService |
||
86 | */ |
||
87 | public function getRepositories() |
||
91 | |||
92 | /** |
||
93 | * @param $name |
||
94 | * @param array $params |
||
95 | * |
||
96 | * @return string |
||
97 | */ |
||
98 | public function generateUrl($name) |
||
102 | |||
103 | /** |
||
104 | * @When /^I hover over the element "([^"]*)"$/ |
||
105 | */ |
||
106 | public function iHoverOverTheElement($locator) |
||
119 | |||
120 | /** |
||
121 | * @Given /^I wait for (\d+) seconds$/ |
||
122 | */ |
||
123 | public function iWaitForSecond($second) |
||
127 | |||
128 | /** |
||
129 | * @Then /^I wait for the ajax response$/ |
||
130 | */ |
||
131 | public function iWaitForTheAjaxResponse() |
||
135 | |||
136 | /** |
||
137 | * Some forms do not have a Submit button just pass the ID |
||
138 | * |
||
139 | * @Given /^I submit the form with id "([^"]*)"$/ |
||
140 | */ |
||
141 | public function iSubmitTheFormWithId($arg) |
||
150 | |||
151 | /** |
||
152 | * @Then I switch to popup :name |
||
153 | * |
||
154 | * @param $name |
||
155 | */ |
||
156 | public function iSwitchToPopup($name) |
||
161 | |||
162 | /** |
||
163 | * @Then I set main window name |
||
164 | */ |
||
165 | public function iSetMainWindowName() |
||
171 | |||
172 | /** |
||
173 | * @Then I switch back to main window |
||
174 | */ |
||
175 | public function iSwitchBackToMainWindow() |
||
179 | |||
180 | public function iVisit($url) |
||
184 | |||
185 | /** |
||
186 | * @When I scroll :selector into view |
||
187 | * |
||
188 | * @param string $selector Allowed selectors: #id, .className, //xpath |
||
189 | * |
||
190 | * @throws \Exception |
||
191 | */ |
||
192 | public function scrollIntoView($selector) |
||
237 | |||
238 | |||
239 | /** |
||
240 | * @When I click location selector |
||
241 | */ |
||
242 | public function iClickLocationSelector() |
||
248 | |||
249 | /** |
||
250 | * @param $locator |
||
251 | * @param string $selector |
||
252 | * |
||
253 | * @return \Behat\Mink\Element\NodeElement|mixed|null |
||
254 | */ |
||
255 | public function getElement($locator,$selector='css') |
||
261 | |||
262 | /** |
||
263 | * @When I fill in location search with :term |
||
264 | * @param $term |
||
265 | */ |
||
266 | public function iFillInLocationSearch($term) |
||
274 | |||
275 | public function iClickOn() |
||
279 | |||
280 | /** |
||
281 | * Click some text |
||
282 | * |
||
283 | * @When /^I click on the text "([^"]*)"$/ |
||
284 | */ |
||
285 | public function iClickOnTheText($text) |
||
305 | |||
306 | } |
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: