From a1a0ad18f6c4df874feb4166b2c3c5be22ed14d0 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Wed, 7 Feb 2024 15:48:25 +0100 Subject: [PATCH] Closes #5316 --- src/Framework/MockObject/MockBuilder.php | 43 +------------------ src/Framework/TestCase.php | 1 - .../MockObject/TestDoubleTestCase.php | 14 ------ 3 files changed, 1 insertion(+), 57 deletions(-) diff --git a/src/Framework/MockObject/MockBuilder.php b/src/Framework/MockObject/MockBuilder.php index 52989c1deb4..95f052a7598 100644 --- a/src/Framework/MockObject/MockBuilder.php +++ b/src/Framework/MockObject/MockBuilder.php @@ -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; @@ -100,7 +99,7 @@ public function getMock(): MockObject $this->originalConstructor, $this->originalClone, $this->autoload, - $this->cloneArguments, + false, $this->callOriginalMethods, $this->proxyTarget, false, @@ -272,46 +271,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 */ diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php index 834667774a1..08bfe55da01 100644 --- a/src/Framework/TestCase.php +++ b/src/Framework/TestCase.php @@ -1418,7 +1418,6 @@ final protected function createPartialMock(string $originalClassName, array $met $mockBuilder = $this->getMockBuilder($originalClassName) ->disableOriginalConstructor() ->disableOriginalClone() - ->disableArgumentCloning() ->onlyMethods($methods); if (!self::generateReturnValuesForTestDoubles()) { diff --git a/tests/unit/Framework/MockObject/TestDoubleTestCase.php b/tests/unit/Framework/MockObject/TestDoubleTestCase.php index d2ae208c018..44f874154fb 100644 --- a/tests/unit/Framework/MockObject/TestDoubleTestCase.php +++ b/tests/unit/Framework/MockObject/TestDoubleTestCase.php @@ -93,20 +93,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);