Skip to content

Commit

Permalink
Closes #5316
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Feb 27, 2024
1 parent 9ba4d35 commit 3dd465e
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 57 deletions.
43 changes: 1 addition & 42 deletions src/Framework/MockObject/MockBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ final class MockBuilder
private bool $originalConstructor = true;
private bool $originalClone = true;
private bool $autoload = true;
private bool $cloneArguments = false;
private bool $callOriginalMethods = false;
private ?object $proxyTarget = null;
private bool $returnValueGeneration = true;
Expand Down Expand Up @@ -101,7 +100,7 @@ public function getMock(): MockObject
$this->originalConstructor,
$this->originalClone,
$this->autoload,
$this->cloneArguments,
false,
$this->callOriginalMethods,
$this->proxyTarget,
false,
Expand Down Expand Up @@ -269,46 +268,6 @@ public function enableAutoload(): self
return $this;
}

/**
* Disables the cloning of arguments passed to mocked methods.
*
* @return $this
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/5315
*/
public function disableArgumentCloning(): self
{
if (!$this->calledFromTestCase()) {
EventFacade::emitter()->testTriggeredPhpunitDeprecation(
$this->testCase->valueObjectForEvents(),
'MockBuilder::disableArgumentCloning() is deprecated and will be removed in PHPUnit 12 without replacement.',
);
}

$this->cloneArguments = false;

return $this;
}

/**
* Enables the cloning of arguments passed to mocked methods.
*
* @return $this
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/5315
*/
public function enableArgumentCloning(): self
{
EventFacade::emitter()->testTriggeredPhpunitDeprecation(
$this->testCase->valueObjectForEvents(),
'MockBuilder::enableArgumentCloning() is deprecated and will be removed in PHPUnit 12 without replacement.',
);

$this->cloneArguments = true;

return $this;
}

/**
* @return $this
*/
Expand Down
1 change: 0 additions & 1 deletion src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,6 @@ final protected function createPartialMock(string $originalClassName, array $met
$mockBuilder = $this->getMockBuilder($originalClassName)
->disableOriginalConstructor()
->disableOriginalClone()
->disableArgumentCloning()
->onlyMethods($methods);

if (!self::generateReturnValuesForTestDoubles()) {
Expand Down
14 changes: 0 additions & 14 deletions tests/unit/Framework/MockObject/TestDoubleTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,6 @@ public function testObjectsPassedAsArgumentAreNotClonedByDefault(): void
$this->assertSame($object, $double->doSomething($object));
}

#[IgnorePhpunitDeprecations]
public function testCloningOfObjectsPassedAsArgumentCanBeEnabled(): void
{
$object = new stdClass;

$double = $this->getMockBuilder(InterfaceWithMethodThatExpectsObject::class)
->enableArgumentCloning()
->getMock();

$double->method('doSomething')->willReturnArgument(0);

$this->assertNotSame($object, $double->doSomething($object));
}

final public function testMethodCanBeConfiguredToReturnOneOfItsArguments(): void
{
$double = $this->createTestDouble(InterfaceWithReturnTypeDeclaration::class);
Expand Down

0 comments on commit 3dd465e

Please sign in to comment.