Marcin Zaremba
Marcin Zaremba

Reputation: 343

PHPUnit - disable original constructor in Mockery

I want use Mockery and change this:

$mockFoo = $this->getMockBuilder('Foo')
        ->disableOriginalConstructor()
        ->getMock();

to this:

$mockFoo = m::mock('Foo');

But I don't know how disable original constructor in Mockery. Please help me if You can. :-)

Upvotes: 6

Views: 4881

Answers (1)

Tim Bezhashvyly
Tim Bezhashvyly

Reputation: 9100

Mockery does not call constructor if no parameters are specified:

\Mockery::mock('MyClass');

UPDATE: The answer above was relevant for earlier versions of Mockery. With the current version one must use partial test doubles:

$mock = \Mockery::mock('MyClass')->makePartial();
$mock->shouldReceive('foo');

See official documentation for more info. Credits go to northerner

Upvotes: 8

Related Questions