I am attempting to test a web service interface class using PHPUnit. Basically, this class makes calls to a SoapClient object. I am attempting to test this class in PHPUnit using the "getMockFromWsdl" method described here:
However, since I want to test multiple methods from this same class, every time I setup the object, I also have to setup the mock WSDL SoapClient object. This is causing a fatal error to be thrown:
Fatal error: Cannot redeclare class xxxx in C:\web\php5\PEAR\PHPUnit\Framework\TestCase.php(1227) : eval()'d code on line 15
How can I use the same mock object across multiple tests without having to regenerate it off the WSDL each time? That seems to be the problem.
--
Having been asked to post some code to look at, here's the setup method in the TestCase:
protected function setUp() {
parent::setUp();
$this->client = new Client();
$this->SoapClient = $this->getMockFromWsdl(
'service.wsdl'
);
$this->client->setClient($this->SoapClient);
}