Closed paulhanssen closed 13 years ago
Please post a small, reproducing test case that I can use to reproduce the issue. Also note that there is no PHPUnit 3.5.17 (yet), the latest version is PHPUnit 3.5.9.
Hi Sebastian,
Thanks for the quick reply, and apologies for the PHPUnit version mistake.
I have knocked up some sample code to try and show what is happening. I hope it is enough for you (let me know otherwise):
<?php
require_once 'PHPUnit/Framework/TestCase.php';
require_once 'Zend/XmlRpc/Client.php';
require_once 'Zend/XmlRpc/Client/ServerProxy.php';
class RemoteRunner
{
protected $_client = null;
public function __construct(Zend_XmlRpc_Client_ServerProxy $client)
{
$this->_client = $client;
}
public function callRemoteMethod($a, $b, $c)
{
return $this->_client->remoteMethod($a, $b, $c);
}
}
class MockErrorTest extends PHPUnit_Framework_TestCase
{
public function testRemoteProcedureCall()
{
$client = $this->getMock('Zend_XmlRpc_Client_ServerProxy',
array('remoteMethod'),
array(new Zend_XmlRpc_Client('testXmlRpcLocation'))
);
$x = (int)0;
$y = (float)1;
$z = 'Z';
$client->expects($this->once())
->method('remoteMethod')
->with($this->equalTo($x), $this->equalTo($y), $this->equalTo($z));
$remoteRunner = new RemoteRunner($client);
$result = $remoteRunner->callRemoteMethod($x, $y, $z);
}
}
I have just been able to produce the following command line (under Windows 7 and PHP 5.3.2 and PHPUnit 3.5.0 so as to run all versions of PHPUnit_MockObject)
c:\temp>pear install phpunit/phpunit_mockobject-1.0.0
downloading PHPUnit_MockObject-1.0.0.tgz ...
Starting to download PHPUnit_MockObject-1.0.0.tgz (17,287 bytes)
......done: 17,287 bytes
install ok: channel://pear.phpunit.de/PHPUnit_MockObject-1.0.0
c:\temp>phpunit MockErrorTest.php
PHPUnit 3.5.0 by Sebastian Bergmann.
.
Time: 0 seconds, Memory: 4.00Mb
OK (1 test, 1 assertion)
c:\temp>pear upgrade phpunit/phpunit_mockobject-1.0.3
downloading PHPUnit_MockObject-1.0.3.tgz ...
Starting to download PHPUnit_MockObject-1.0.3.tgz (17,333 bytes)
......done: 17,333 bytes
upgrade ok: channel://pear.phpunit.de/PHPUnit_MockObject-1.0.3
c:\temp>phpunit MockErrorTest.php
PHPUnit 3.5.0 by Sebastian Bergmann.
.
Time: 0 seconds, Memory: 3.75Mb
OK (1 test, 1 assertion)
c:\temp>pear upgrade phpunit/phpunit_mockobject-1.0.4
downloading PHPUnit_MockObject-1.0.4.tgz ...
Starting to download PHPUnit_MockObject-1.0.4.tgz (17,879 bytes)
......done: 17,879 bytes
upgrade ok: channel://pear.phpunit.de/PHPUnit_MockObject-1.0.4
c:\temp>phpunit MockErrorTest.php
PHPUnit 3.5.0 by Sebastian Bergmann.
F
Time: 0 seconds, Memory: 4.00Mb
There was 1 failure:
1) MockErrorTest::testRemoteProcedureCall
Expectation failed for method name is equal to <string:remoteMethod> when invoked 1 time(s)
Parameter count for invocation Zend_XmlRpc_Client_ServerProxy::remoteMethod() is too low.
C:\temp\MockErrorTest.php:18
C:\temp\MockErrorTest.php:41
FAILURES!
Tests: 1, Assertions: 0, Failures: 1.
c:\temp>pear upgrade phpunit/phpunit_mockobject-1.0.5
downloading PHPUnit_MockObject-1.0.5.tgz ...
Starting to download PHPUnit_MockObject-1.0.5.tgz (18,000 bytes)
......done: 18,000 bytes
upgrade ok: channel://pear.phpunit.de/PHPUnit_MockObject-1.0.5
c:\temp>phpunit MockErrorTest.php
PHPUnit 3.5.0 by Sebastian Bergmann.
F
Time: 0 seconds, Memory: 4.00Mb
There was 1 failure:
1) MockErrorTest::testRemoteProcedureCall
Expectation failed for method name is equal to <string:remoteMethod> when invoked 1 time(s)
Parameter count for invocation Zend_XmlRpc_Client_ServerProxy::remoteMethod(<double:1>, <string:Z>) is too low.
C:\temp\MockErrorTest.php:18
C:\temp\MockErrorTest.php:41
FAILURES!
Tests: 1, Assertions: 0, Failures: 1.
c:\temp>
Regards, Paul
The method that is to be mocked, remoteMethod()
, does not exist. Closing, because it is a duplicate of issue #35.
The stubbing/mocking of undeclared methods used to work before the patch that fixed issue #3.
With PHPUnit_MockObject-1.0.5 (PHPUnit 3.5.17) I run into the following style of errors when mocking Zend_XmlRpc_Client_ServerProxy objects:
The error is not reported under PHPUnit_MockObject-1.0.0.