lundi 1 juin 2015

Cannot set public property on Mockery mock object

I'm trying to use Mockery to create a mock object that mimics PHP's internal ZipArchive class.

I have something like the following PHP code:

$zipMock = Mockery::mock('ZipArchive');
$zipMock->numFiles = 10;
echo 'NUMBER OF FILES: '.$zipMock->numFiles;

However, when I run it I get the following result:

NUMBER OF FILES: 0

I'd expect it to show 10, rather than 0. I can't work out why this is happening since the documentation implies that it should be possible to set public properties on mock objects directly. What am I missing?

Aucun commentaire:

Enregistrer un commentaire