Dummy
$dummy = $this->prophesize(SomeClass::class); $sut->action($dummy->reveal());
Stub
$stub = $this->prophesize(SomeClass::class); $stub->getSomething()->willReturn('foo'); $sut->action($stub->reveal()); // with phpspec class MarkdownSpec extends ObjectBehavior { function it_converts_text_from_an_external_source(Reader $reader) { $reader->getMarkdown()->willReturn("Hi, there"); $this->toHtmlFromReader($reader)->shouldReturn("Hi, there"); } }
Mock
$mock = $this->prophesize(SomeClass::class); $mock->doSomething('bar')->shouldBeCalled(); $sut->action($mock->reveal()); // with phpspec class MarkdownSpec extends ObjectBehavior { function it_outputs_converted_text(Writer $writer) { $writer->writeText("Hi, there")->shouldBeCalled(); $this->outputHtml("Hi, there", $writer); } }
Spy
$spy = $this->prophesize(SomeClass::class); $sut->action($spy->reveal()); $spy->doSomething('bar')->shouldHaveBeenCalled(); // with phpspec class MarkdownSpec extends ObjectBehavior { function it_outputs_converted_text(Writer $writer) { $this->outputHtml("Hi, there", $writer); $writer->writeText("Hi, there")->shouldHaveBeenCalled(); } }