Created
May 17, 2018 06:41
-
-
Save benrowe/527c9f0b2800293e9b180a48cd926f85 to your computer and use it in GitHub Desktop.
PHPUnit Test Examples
This file contains hidden or 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
public function testConstructorCallsMethod() | |
{ | |
$callMethod = 'init' | |
$mock = $this | |
->getMockBuilder(ClassToTest::class) | |
->disableOriginalConstructor() | |
->getMock(); | |
$mock | |
->expects($this->once()) | |
->method($callMethod); | |
$reflectClass = new \ReflectionClass(ClassToTest::class); | |
$constructor = $reflectClass->getConstructor(); | |
$constructor->invoke($mock, $args, $for, $constructor); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment