1 | <?php |
||
14 | class DrupalContext extends RawDrupalContext { |
||
15 | |||
16 | /** |
||
17 | * Assert access denied page. |
||
18 | * |
||
19 | * @Then I should get an access denied error |
||
20 | */ |
||
21 | public function assertAccessDenied() { |
||
24 | |||
25 | /** |
||
26 | * Pause execution for given number of seconds. |
||
27 | * |
||
28 | * @Then I wait :seconds seconds |
||
29 | */ |
||
30 | public function iWaitSeconds($seconds) { |
||
33 | |||
34 | /** |
||
35 | * Creates content by filling specified form fields via the UI. |
||
36 | * |
||
37 | * Use as follow: |
||
38 | * |
||
39 | * | Title | Author | Label | of the field | |
||
40 | * | My title | Joe Editor | 1 | 2014-10-17 8:00am | |
||
41 | * | ... | ... | ... | ... | |
||
42 | * |
||
43 | * @Given I create :type content: |
||
44 | */ |
||
45 | public function manuallyCreateNodes($type, TableNode $nodesTable) { |
||
64 | |||
65 | /** |
||
66 | * Assert string in HTTP response header. |
||
67 | * |
||
68 | * @Then I should see in the header :header::value |
||
69 | */ |
||
70 | public function iShouldSeeInTheHeader($header, $value) { |
||
76 | |||
77 | /** |
||
78 | * Invalidate cache tags. |
||
79 | * |
||
80 | * Usage: |
||
81 | * |
||
82 | * Given I invalidate the following cache tags: |
||
83 | * | tag_one | |
||
84 | * | tag_two | |
||
85 | * |
||
86 | * @Given I invalidate the following cache tags: |
||
87 | */ |
||
88 | public function invalidateCacheTags(TableNode $table) { |
||
95 | |||
96 | } |
||
97 |
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: