| 1 | <?php |
||
| 13 | final class UserCallableTest extends TestCase |
||
| 14 | { |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var ObjectProphecy|User |
||
| 18 | */ |
||
| 19 | private $userMock; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var UserCallable |
||
| 23 | */ |
||
| 24 | private $userCallable; |
||
| 25 | |||
| 26 | |||
| 27 | protected function setUp() |
||
| 28 | { |
||
| 29 | $this->userMock = $this->prophesize(User::class); |
||
| 30 | $this->userMock->getId()->willReturn(1); |
||
| 31 | $this->userMock->isLoggedIn()->willReturn(TRUE); |
||
| 32 | $this->userCallable = new UserCallable($this->userMock->reveal()); |
||
| 33 | } |
||
| 34 | |||
| 35 | |||
| 36 | public function testInvoke() |
||
| 43 | |||
| 44 | } |
||
| 45 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: