1 | <?php |
||
23 | class FeatureContext extends MinkContext implements SnippetAcceptingContext |
||
24 | { |
||
25 | use KernelDictionary; |
||
26 | |||
27 | /** |
||
28 | * @var bool |
||
29 | */ |
||
30 | private $result; |
||
31 | |||
32 | /** |
||
33 | * @Given I am logged in as :username |
||
34 | */ |
||
35 | public function iAmAnLoggedInAs($username) |
||
50 | |||
51 | /** |
||
52 | * @Given I am on the page :uri |
||
53 | */ |
||
54 | public function iAmOnThePage($uri) |
||
59 | |||
60 | /** |
||
61 | * @When I want to verify if I am granted :grant |
||
62 | */ |
||
63 | public function iWantToVerifyIfIsGranted($grant) |
||
67 | |||
68 | /** |
||
69 | * @Then I should get true |
||
70 | */ |
||
71 | public function iShouldGetTrue() |
||
77 | |||
78 | /** |
||
79 | * @Then I should get false |
||
80 | */ |
||
81 | public function iShouldGetFalse() |
||
87 | } |
||
88 |
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: