Your code is using the actual code for selectWith
. This calls an initialize
method that throws your error.
Change you mock code to:
$mockTableGateway = $this->getMock(
'Zend\Db\TableGateway\TableGateway',
array('selectWith','getTable'),
array(),
'',
false
);
This should properly configure your mock.
http://phpunit.de/manual/current/en/test-doubles.html
From the manual:
When the second (optional) parameter is provided, only the methods whose names are in the array are replaced with a configurable test double. The behavior of the other methods is not changed. Providing NULL as the parameter means that no methods will be replaced.
So you were setting the expects on the correct method, but were replacing the wrong one with your mock and so the real code was being executed.