Skip to content

Instantly share code, notes, and snippets.

@joshlopes
Created February 1, 2019 15:55
Show Gist options
  • Save joshlopes/6aa8a80fdaa31e65382b5a6acd7c33a1 to your computer and use it in GitHub Desktop.
Save joshlopes/6aa8a80fdaa31e65382b5a6acd7c33a1 to your computer and use it in GitHub Desktop.
class ExampleTest extends BaseTestCase
{
public function testA()
{
$contact1 = new Contact();
$contact2 = new Contact();
$this->prophesize();
$mockB = $this->prophesize(B::class);
$mockB->doStuff($contact2)->shouldBeCalled();
$instanceA = new A($mockB->reveal());
$instanceA->doStuff($contact1);
}
}
class A
{
/**
* @var B
*/
private $classB;
public function __construct(B $classB)
{
$this->classB = $classB;
}
public function doStuff(Contact $contact)
{
$this->classB->doStuff($contact);
}
}
class B
{
public function doStuff(Contact $contact)
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment