Skip to content
This repository was archived by the owner on Feb 20, 2023. It is now read-only.

Commit 447a514

Browse files
Merge pull request #112 from whatthejeff/issue_argument_cloning
2 parents f02c89e + d2d3e44 commit 447a514

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

PHPUnit/Framework/MockObject/Generator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@ public static function generate($originalClassName, array $methods = NULL, $mock
382382
$key = md5(
383383
$originalClassName .
384384
serialize($methods) .
385-
serialize($callOriginalClone)
385+
serialize($callOriginalClone) .
386+
serialize($cloneArguments)
386387
);
387388

388389
if (isset(self::$cache[$key])) {

Tests/MockObjectTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,22 @@ public function testObjectMethodCallWithArgumentCloningDisabled()
464464
$mock->doSomethingElse($expectedObject);
465465

466466
$this->assertEquals(1, count($actualArguments));
467-
$this->assertNotSame($expectedObject, $actualArguments[0]);
467+
$this->assertSame($expectedObject, $actualArguments[0]);
468+
}
469+
470+
public function testArgumentCloningOptionGeneratesUniqueMock()
471+
{
472+
$mockWithCloning = $this->getMockBuilder('SomeClass')
473+
->setMethods(array('doSomethingElse'))
474+
->enableArgumentCloning()
475+
->getMock();
476+
477+
$mockWithoutCloning = $this->getMockBuilder('SomeClass')
478+
->setMethods(array('doSomethingElse'))
479+
->disableArgumentCloning()
480+
->getMock();
481+
482+
$this->assertNotEquals($mockWithCloning, $mockWithoutCloning);
468483
}
469484

470485
public function testVerificationOfMethodNameFailsWithoutParameters()

0 commit comments

Comments
 (0)