From d5ff1689403354979e98b8a66e70a6d006f92992 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Wed, 7 Feb 2024 15:35:43 +0100 Subject: [PATCH] Closes #5246 --- .phpstorm.meta.php | 5 --- src/Framework/TestCase.php | 34 ---------------- tests/static-analysis/TestUsingMocks.php | 11 ----- .../Creation/CreateTestProxyTest.php | 40 ------------------- 4 files changed, 90 deletions(-) delete mode 100644 tests/unit/Framework/MockObject/Creation/CreateTestProxyTest.php diff --git a/.phpstorm.meta.php b/.phpstorm.meta.php index af7fbb3e516..667752b0f74 100644 --- a/.phpstorm.meta.php +++ b/.phpstorm.meta.php @@ -25,9 +25,4 @@ \PHPUnit\Framework\TestCase::createPartialMock(0), map([""=>"$0"]) ); - - override( - \PHPUnit\Framework\TestCase::createTestProxy(0), - map([""=>"$0"]) - ); } diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php index f8a978150a6..a967a8b2d95 100644 --- a/src/Framework/TestCase.php +++ b/src/Framework/TestCase.php @@ -1381,40 +1381,6 @@ final protected function createPartialMock(string $originalClassName, array $met return $partialMock; } - /** - * Creates a test proxy for the specified class. - * - * @psalm-template RealInstanceType of object - * - * @psalm-param class-string $originalClassName - * - * @psalm-return MockObject&RealInstanceType - * - * @throws InvalidArgumentException - * @throws MockObjectException - * - * @deprecated https://github.com/sebastianbergmann/phpunit/issues/5240 - */ - final protected function createTestProxy(string $originalClassName, array $constructorArguments = []): MockObject - { - Event\Facade::emitter()->testTriggeredPhpunitDeprecation( - $this->valueObjectForEvents(), - 'createTestProxy() is deprecated and will be removed in PHPUnit 12 without replacement.', - ); - - $testProxy = $this->getMockBuilder($originalClassName) - ->setConstructorArgs($constructorArguments) - ->enableProxyingToOriginalMethods() - ->getMock(); - - Event\Facade::emitter()->testCreatedTestProxy( - $originalClassName, - $constructorArguments, - ); - - return $testProxy; - } - protected function transformException(Throwable $t): Throwable { return $t; diff --git a/tests/static-analysis/TestUsingMocks.php b/tests/static-analysis/TestUsingMocks.php index 24770e4c0d6..f591ac34a30 100644 --- a/tests/static-analysis/TestUsingMocks.php +++ b/tests/static-analysis/TestUsingMocks.php @@ -68,17 +68,6 @@ public function testWillSayHelloThroughCreatePartialMock(): void self::assertSame('hello mock!', $mock->sayHello()); } - public function testWillSayHelloThroughCreateTestProxy(): void - { - $mock = $this->createTestProxy(HelloWorldClass::class, []); - - $mock - ->method('sayHello') - ->willReturn('hello mock!'); - - self::assertSame('hello mock!', $mock->sayHello()); - } - public function testWillSayHelloThroughGetMockBuilder(): void { $mock = $this diff --git a/tests/unit/Framework/MockObject/Creation/CreateTestProxyTest.php b/tests/unit/Framework/MockObject/Creation/CreateTestProxyTest.php deleted file mode 100644 index 9ca8cd00720..00000000000 --- a/tests/unit/Framework/MockObject/Creation/CreateTestProxyTest.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace PHPUnit\Framework\MockObject; - -use function assert; -use PHPUnit\Framework\Attributes\Group; -use PHPUnit\Framework\Attributes\IgnorePhpunitDeprecations; -use PHPUnit\Framework\Attributes\Medium; -use PHPUnit\Framework\Attributes\TestDox; -use PHPUnit\Framework\TestCase; -use PHPUnit\TestFixture\MockObject\TestProxyFixture; - -#[Group('test-doubles')] -#[Group('test-doubles/creation')] -#[Group('test-doubles/test-proxy')] -#[Medium] -#[TestDox('createTestProxy()')] -#[IgnorePhpunitDeprecations] -final class CreateTestProxyTest extends TestCase -{ - public function testCreatesTestProxyForExtendableClass(): void - { - $proxy = $this->createTestProxy(TestProxyFixture::class); - - $proxy->expects($this->once()) - ->method('returnString'); - - assert($proxy instanceof MockObject); - assert($proxy instanceof TestProxyFixture); - - $this->assertSame('result', $proxy->returnString()); - } -}