1 | <?php |
||
15 | class DrupalContext extends RawDrupalContext implements SnippetAcceptingContext { |
||
16 | |||
17 | /** |
||
18 | * Assert access denied page. |
||
19 | * |
||
20 | * @Then I should get an access denied error |
||
21 | */ |
||
22 | public function assertAccessDenied() { |
||
25 | |||
26 | /** |
||
27 | * Pause execution for given number of seconds. |
||
28 | * |
||
29 | * @Then I wait :seconds seconds |
||
30 | */ |
||
31 | public function iWaitSeconds($seconds) { |
||
34 | |||
35 | /** |
||
36 | * Creates content by filling specified form fields via the UI. |
||
37 | * |
||
38 | * Use as follow: |
||
39 | * |
||
40 | * | Title | Author | Label | of the field | |
||
41 | * | My title | Joe Editor | 1 | 2014-10-17 8:00am | |
||
42 | * | ... | ... | ... | ... | |
||
43 | * |
||
44 | * @Given I create :type content: |
||
45 | */ |
||
46 | public function manuallyCreateNodes($type, TableNode $nodesTable) { |
||
65 | |||
66 | /** |
||
67 | * Assert string in HTTP response header. |
||
68 | * |
||
69 | * @Then I should see in the header :header::value |
||
70 | */ |
||
71 | public function iShouldSeeInTheHeader($header, $value) { |
||
77 | |||
78 | } |
||
79 |
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: