Created
February 1, 2019 15:55
-
-
Save joshlopes/6aa8a80fdaa31e65382b5a6acd7c33a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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