1 | <?php |
||
23 | class TestListener extends \PHPUnit_Framework_BaseTestListener |
||
24 | { |
||
25 | /** |
||
26 | * endTest is called after each test and checks if \Mockery::close() has |
||
27 | * been called, and will let the test fail if it hasn't. |
||
28 | * |
||
29 | * @param PHPUnit_Framework_Test $test |
||
30 | * @param float $time |
||
31 | */ |
||
32 | 2 | public function endTest(\PHPUnit_Framework_Test $test, $time) |
|
50 | } |
||
51 |
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: