Disabling constructor in Prophecy

1.4k Views Asked by At

I have a Symfony class I am trying to mock using Prophecy. However, when I reveal the class it executes the constructor. Below is example code:

$mock = $this->prophesize('Symfony\Component\HttpFoundation\File\UploadedFile');
$mock->reveal();

which returns the exception

Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException

which doesn't make sense to me as Prophecy is supposed to automatically disable the constructor?

1

There are 1 best solutions below

0
On BEST ANSWER

I had the same problem and had to mock without prophecy:

$uploadedFile = $this->getMockBuilder(UploadedFile::class)->disableOriginalC‌​onstructor()->getMoc‌​k();

Probably related https://github.com/phpspec/prophecy/issues/58