|
|
Choosing A Webhost: |
Re: [PHPUnit] #119: Testing with mock objects fail if an object does not al: msg#00041php.phpunit.devel
#119: Testing with mock objects fail if an object does not allow cloning. -----------------------+---------------------------------------------------- Reporter: lomat | Owner: sb Type: defect | Status: assigned Priority: major | Milestone: PHPUnit 3.1 Component: phpunit | Version: 3.0.6 Resolution: | Keywords: Mock Objects Php_version: 5.2.0 | -----------------------+---------------------------------------------------- Comment (by sb): Replying to [comment:2 sb]: > Please test with the patch below: Correct patch: {{{ Index: Framework/MockObject/Invocation.php =================================================================== --- Framework/MockObject/Invocation.php (revision 612) +++ Framework/MockObject/Invocation.php (working copy) @@ -87,7 +87,7 @@ foreach ($this->parameters as $key => $value) { if (is_object($value)) { - $this->parameters[$key] = clone $value; + $this->parameters[$key] = $this->cloneObject($value); } } } @@ -111,5 +111,28 @@ ) ); } + + protected function cloneObject($original) + { + $object = new ReflectionObject($original); + + if ($object->hasMethod('__clone')) { + $method = $object->getMethod('__clone'); + + if (!$method->isPublic()) { + return $original; + } + + try { + return clone $original; + } + + catch (Exception $e) { + return $original; + } + } + + return clone $original; + } } ?> }}} -- Ticket URL: <http://www.phpunit.de/ticket/119#comment:3> PHPUnit <http://www.phpunit.de/>
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: [PHPUnit] #119: Testing with mock objects fail if an object does not allow cloning., PHPUnit |
|---|---|
| Next by Date: | [PHPUnit] #121: Request phpunit command-line option that sets stop=TRUE after failure, PHPUnit |
| Previous by Thread: | Re: [PHPUnit] #119: Testing with mock objects fail if an object does not allow cloning., PHPUnit |
| Next by Thread: | Re: [PHPUnit] #119: Testing with mock objects fail if an object does not allow cloning., PHPUnit |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |