1 | <?php |
||
12 | class TaxonomyTermContext extends RawDrupalContext { |
||
13 | |||
14 | /** |
||
15 | * Visit taxonomy term page given its type and name. |
||
16 | * |
||
17 | * @Given I visit the :type term :title |
||
18 | * @Given I am visiting the :type term :title |
||
19 | */ |
||
20 | public function iAmViewingTheTerm($type, $title) { |
||
23 | |||
24 | /** |
||
25 | * Visit taxonomy term edit page given its type and name. |
||
26 | * |
||
27 | * @Given I am editing the :type term :title |
||
28 | * @Given I edit the :type term :title |
||
29 | */ |
||
30 | public function iAmEditingTheTerm($type, $title) { |
||
33 | |||
34 | /** |
||
35 | * Visit taxonomy term delete page given its type and name. |
||
36 | * |
||
37 | * @Given I am deleting the :type term :title |
||
38 | * @Given I delete the :type term :title |
||
39 | */ |
||
40 | public function iAmDeletingTheTerm($type, $title) { |
||
43 | |||
44 | /** |
||
45 | * Provides a common step definition callback for taxonomy term pages. |
||
46 | * |
||
47 | * @param string $op |
||
48 | * The operation being performed: 'view', 'edit', 'delete'. |
||
49 | * @param string $type |
||
50 | * The term's vocabulary, either as machine name or label. |
||
51 | * @param string $name |
||
52 | * The term name. |
||
53 | * |
||
54 | * @throws ExpectationException |
||
55 | * When the term does not exist. |
||
56 | */ |
||
57 | protected function visitTermPage($op, $type, $name) { |
||
73 | |||
74 | } |
||
75 |
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: