Slide 13
Slide 13 text
Self-shunt spy
class ServiceTest extends TestCase
implements CollaboratorInterface
{
private $collaboratorCalls = 0;
public function testSomething()
{
$serviceUnderTest = new Service($this);
$result = $serviceUnderTest->execute();
$this->assertEquals(‘expected’, $result);
$this->assertEquals(1, $this->collaboratorCalls);
}
public function doThatThing(): string
{
$this->collaboratorCalls+;
return ‘something’;
}
}