dimanche 23 août 2015

Phpunit, mock constructor?

I want to mock the constructor like any other methods. I also added a willReturnCallback clause, which does not seem to work. I mean, it all works with methods, but not with the constructor.

$mock = $this->getMock ('MyClass', array(), array(), '', false);
$mock->expects($this->once())->method('__construct')->willReturnCallback(function() { echo 'outputt'; });

so mocking constructor has no effect.

Aucun commentaire:

Enregistrer un commentaire