Navigation Menu

Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Dec 3, 2016
1 parent a974d03 commit 55d2148
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
25 changes: 12 additions & 13 deletions src/Framework/TestCase.php
Expand Up @@ -2606,13 +2606,11 @@ private function registerMockObjectsFromTestArguments(array $testArguments)
} else {
foreach ($testArguments as $testArgument) {
if ($testArgument instanceof PHPUnit_Framework_MockObject_MockObject) {
$original = $testArgument;

if ($this->isSaveCloneForMockObjectsFromTestArguments(new ReflectionObject($original))) {
$original = clone $original;
if ($this->isCloneable($testArgument)) {
$testArgument = clone $testArgument;
}

$this->registerMockObject($original);
$this->registerMockObject($testArgument);
} elseif (is_array($testArgument)) {
$this->registerMockObjectsFromTestArguments($testArgument);
}
Expand All @@ -2633,20 +2631,21 @@ private function setDoesNotPerformAssertionsFromAnnotation()
}

/**
* @param ReflectionObject $reflection
* @param PHPUnit_Framework_MockObject_MockObject $testArgument
*
* @return bool
*/
private function isSaveCloneForMockObjectsFromTestArguments(ReflectionObject $reflection)
private function isCloneable(PHPUnit_Framework_MockObject_MockObject $testArgument)
{
if (method_exists($reflection, 'isCloneable') && !$reflection->isCloneable()) {
$reflector = new ReflectionObject($testArgument);

if (!$reflector->isCloneable()) {
return false;
}

if ($reflection->hasMethod('__clone')) {
$method = $reflection->getMethod('__clone');
if ($method->isPublic()) {
return true;
}
if ($reflector->hasMethod('__clone') &&
$reflector->getMethod('__clone')->isPublic()) {
return true;
}

return false;
Expand Down
1 change: 0 additions & 1 deletion tests/Regression/GitHub/2382/Issue2382Test.php
Expand Up @@ -3,7 +3,6 @@

class Issue2382Test extends TestCase
{

/**
* @dataProvider dataProvider
*/
Expand Down

0 comments on commit 55d2148

Please sign in to comment.