jeudi 14 janvier 2021

PHP Prophecy ->reveal() method - should I put the expectations (like "willReturn", "ShouldBeCalled") before or after it?

Working with PHP Prophecy now. I have two codes samples: One:

$aProphecy = $this->prophesize(A::class);
$aProphecy->someMethod()->willReturn([]);
//now can be used:
$aProphecy->reveal();

Two

$aProphecy = $this->prophesize(A::class);
$aProphecy->reveal();
$aProphecy->someMethod()->willReturn([]);

I can't understand which is the correct way, and why?

Aucun commentaire:

Enregistrer un commentaire