Re: Re: Mock objects with PHPUnit2
| From: | Rob Young | Date: | Mon, 23 Jan 2006 17:31:45 +0000 |
| Subject: | Re: Re: Mock objects with PHPUnit2 | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-22645@lists.php.net to get a copy of this message | ||
Sebastian Bergmann wrote:
Constructor methods are not mocked by PHPUnit's mock object code generator. Don't know if that answers your question, though. Not really I'm afraid. The issue I'm having is that if the class I want to mock expects parameters to be passed to it then I get a warning. Take the following.class ToBeMocked { public function __contruct( $param1 ) {
// Do something with $param1} public function something() { } } // Inside a test //--SNIP-- $mock = $this->getMock('ToBeMocked', array('something')); //--SNIP-- With this I would get the following warning Warning: Missing argument 1 for Mock_ToBeMocked::__construct(), called in /usr/local/lib/php/PHPUnit2/Framework/Assert.php on line 956 and defined in /usr/local/lib/php/PHPUnit2/Extensions/MockObject/Mock.php(141) : eval()'d code on line 4 Cheers Rob