Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
PHPUnit Test Examples
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