diff --git a/.phpstorm.meta.php b/.phpstorm.meta.php index af7fbb3e51..667752b0f7 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 42a8e01646..2b65133251 100644 --- a/src/Framework/TestCase.php +++ b/src/Framework/TestCase.php @@ -1436,41 +1436,6 @@ final protected function createPartialMock(string $originalClassName, array $met return $partialMock; } - /** - * Creates a test proxy for the specified class. - * - * @template RealInstanceType of object - * - * @param class-string $originalClassName - * @param array $constructorArguments - * - * @throws InvalidArgumentException - * @throws MockObjectException - * - * @return MockObject&RealInstanceType - * - * @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 24770e4c0d..f591ac34a3 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 9ca8cd0072..0000000000 --- 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()); - } -}