From 05dd2177bfda884c0b7c685561f1064d4377102e Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Wed, 7 Feb 2024 15:44:47 +0100 Subject: [PATCH] Closes #5311 --- src/Framework/MockObject/MockBuilder.php | 57 +++++------------------- src/Framework/TestCase.php | 1 - 2 files changed, 10 insertions(+), 48 deletions(-) diff --git a/src/Framework/MockObject/MockBuilder.php b/src/Framework/MockObject/MockBuilder.php index c187d9701e7..94b4d8a9492 100644 --- a/src/Framework/MockObject/MockBuilder.php +++ b/src/Framework/MockObject/MockBuilder.php @@ -52,16 +52,15 @@ final class MockBuilder /** * @psalm-var ?class-string */ - private ?string $mockClassName = null; - private array $constructorArgs = []; - 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 $allowMockingUnknownTypes = true; - private bool $returnValueGeneration = true; + private ?string $mockClassName = null; + private array $constructorArgs = []; + 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; private readonly Generator $generator; /** @@ -106,7 +105,7 @@ public function getMock(): MockObject $this->cloneArguments, $this->callOriginalMethods, $this->proxyTarget, - $this->allowMockingUnknownTypes, + false, $this->returnValueGeneration, ); @@ -311,42 +310,6 @@ public function enableArgumentCloning(): self return $this; } - /** - * @return $this - * - * @deprecated https://github.com/sebastianbergmann/phpunit/issues/5308 - */ - public function allowMockingUnknownTypes(): self - { - EventFacade::emitter()->testTriggeredPhpunitDeprecation( - $this->testCase->valueObjectForEvents(), - 'MockBuilder::allowMockingUnknownTypes() is deprecated and will be removed in PHPUnit 12 without replacement.', - ); - - $this->allowMockingUnknownTypes = true; - - return $this; - } - - /** - * @return $this - * - * @deprecated https://github.com/sebastianbergmann/phpunit/issues/5308 - */ - public function disallowMockingUnknownTypes(): self - { - if (!$this->calledFromTestCase()) { - EventFacade::emitter()->testTriggeredPhpunitDeprecation( - $this->testCase->valueObjectForEvents(), - 'MockBuilder::disallowMockingUnknownTypes() is deprecated and will be removed in PHPUnit 12 without replacement.', - ); - } - - $this->allowMockingUnknownTypes = false; - - return $this; - } - /** * @return $this */ diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php index a967a8b2d95..5893f3f8f99 100644 --- a/src/Framework/TestCase.php +++ b/src/Framework/TestCase.php @@ -1364,7 +1364,6 @@ final protected function createPartialMock(string $originalClassName, array $met ->disableOriginalConstructor() ->disableOriginalClone() ->disableArgumentCloning() - ->disallowMockingUnknownTypes() ->onlyMethods($methods); if (!self::generateReturnValuesForTestDoubles()) {