I'm using Prophecy in my unit test, I want to mock all methods in user object
class User {
public function age()
{
return date("Y") - $this->born();
}
public function born()
{
// Database call or anything else, it's a black box !
}
}
I want to test my the age when the method born changed
public function testProphecyAge()
{
$user = $this->prophesize(User::class);
$user->born()
->willReturn(2018)
->shouldBeCalled();
$user = $user->reveal();
$this->assertEquals(1, $user->age());
}
I get the error
Prophecy\Exception\Call\UnexpectedCallException: Unexpected method call on Double\User\P1
Aucun commentaire:
Enregistrer un commentaire