From 593df344d5ab0d19eba78bbad24e433aace6c0b5 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Sun, 6 Oct 2024 17:08:57 +0200 Subject: [PATCH] Closes #5314 --- ChangeLog-12.0.md | 1 + DEPRECATIONS.md | 1 - src/Framework/MockObject/MockBuilder.php | 36 ------------------- .../MockObject/Creation/MockBuilderTest.php | 13 ------- 4 files changed, 1 insertion(+), 50 deletions(-) diff --git a/ChangeLog-12.0.md b/ChangeLog-12.0.md index 83218dbb11c..92f9d945150 100644 --- a/ChangeLog-12.0.md +++ b/ChangeLog-12.0.md @@ -7,6 +7,7 @@ All notable changes of the PHPUnit 12.0 release series are documented in this fi ### Removed * [#5247](https://github.com/sebastianbergmann/phpunit/issues/5247): `TestCase::getMockForAbstractClass()` +* [#5314](https://github.com/sebastianbergmann/phpunit/issues/5314): `MockBuilder::getMockForAbstractClass()` * [#5978](https://github.com/sebastianbergmann/phpunit/issues/5978): Support for PHP 8.2 [12.0.0]: https://github.com/sebastianbergmann/phpunit/compare/11.5...main diff --git a/DEPRECATIONS.md b/DEPRECATIONS.md index 580dff34a54..4f4fd327489 100644 --- a/DEPRECATIONS.md +++ b/DEPRECATIONS.md @@ -21,7 +21,6 @@ This functionality is currently [hard-deprecated](https://phpunit.de/backward-co | [#5242](https://github.com/sebastianbergmann/phpunit/issues/5242) | `TestCase::getMockFromWsdl()` | 10.1.0 | | | [#5243](https://github.com/sebastianbergmann/phpunit/issues/5243) | `TestCase::getMockForTrait()` | 10.1.0 | | | [#5244](https://github.com/sebastianbergmann/phpunit/issues/5244) | `TestCase::getObjectForTrait()` | 10.1.0 | | -| [#5305](https://github.com/sebastianbergmann/phpunit/issues/5305) | `MockBuilder::getMockForAbstractClass()` | 10.1.0 | | | [#5306](https://github.com/sebastianbergmann/phpunit/issues/5306) | `MockBuilder::getMockForTrait()` | 10.1.0 | | | [#5307](https://github.com/sebastianbergmann/phpunit/issues/5307) | `MockBuilder::disableProxyingToOriginalMethods()` | 10.1.0 | | | [#5307](https://github.com/sebastianbergmann/phpunit/issues/5307) | `MockBuilder::enableProxyingToOriginalMethods()` | 10.1.0 | | diff --git a/src/Framework/MockObject/MockBuilder.php b/src/Framework/MockObject/MockBuilder.php index e51ae8c62a6..f96e248e58b 100644 --- a/src/Framework/MockObject/MockBuilder.php +++ b/src/Framework/MockObject/MockBuilder.php @@ -123,42 +123,6 @@ public function getMock(): MockObject return $object; } - /** - * Creates a mock object for an abstract class using a fluent interface. - * - * @throws Exception - * @throws ReflectionException - * @throws RuntimeException - * - * @return MockedType&MockObject - * - * @deprecated https://github.com/sebastianbergmann/phpunit/issues/5305 - */ - public function getMockForAbstractClass(): MockObject - { - EventFacade::emitter()->testTriggeredPhpunitDeprecation( - $this->testCase->valueObjectForEvents(), - 'MockBuilder::getMockForAbstractClass() is deprecated and will be removed in PHPUnit 12 without replacement.', - ); - - $object = $this->generator->mockObjectForAbstractClass( - $this->type, - $this->constructorArgs, - $this->mockClassName ?? '', - $this->originalConstructor, - $this->originalClone, - $this->autoload, - $this->methods, - $this->cloneArguments, - ); - - assert($object instanceof MockObject); - - $this->testCase->registerMockObject($object); - - return $object; - } - /** * Creates a mock object for a trait using a fluent interface. * diff --git a/tests/unit/Framework/MockObject/Creation/MockBuilderTest.php b/tests/unit/Framework/MockObject/Creation/MockBuilderTest.php index 84111d36dd1..13fdda1938b 100644 --- a/tests/unit/Framework/MockObject/Creation/MockBuilderTest.php +++ b/tests/unit/Framework/MockObject/Creation/MockBuilderTest.php @@ -26,7 +26,6 @@ use PHPUnit\Framework\MockObject\Generator\InvalidMethodNameException; use PHPUnit\Framework\MockObject\Generator\NameAlreadyInUseException; use PHPUnit\Framework\TestCase; -use PHPUnit\TestFixture\MockObject\AbstractClass; use PHPUnit\TestFixture\MockObject\ExtendableClass; use PHPUnit\TestFixture\MockObject\ExtendableClassCallingMethodInConstructor; use PHPUnit\TestFixture\MockObject\InterfaceWithReturnTypeDeclaration; @@ -113,18 +112,6 @@ public function testCannotCreateMockObjectForExtendableClassAddingMethodToItWith ->getMock(); } - #[IgnorePhpunitDeprecations] - #[TestDox('getMockForAbstractClass() can be used to create a mock object for an abstract class')] - public function testCreatesMockObjectForAbstractClassAndAllowsConfigurationOfAbstractMethods(): void - { - $double = $this->getMockBuilder(AbstractClass::class) - ->getMockForAbstractClass(); - - $double->expects($this->once())->method('doSomethingElse')->willReturn(true); - - $this->assertTrue($double->doSomething()); - } - #[IgnorePhpunitDeprecations] #[TestDox('getMockForTrait() can be used to create a mock object for a trait')] public function testCreatesMockObjectForTraitAndAllowsConfigurationOfMethods(): void