diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php index 8b66111b704..8e487ee1449 100644 --- a/src/Framework/TestCase.php +++ b/src/Framework/TestCase.php @@ -1479,31 +1479,6 @@ final protected function getMockFromWsdl(string $wsdlFile, string $originalClass return $mockObject; } - /** - * Creates an object that uses the specified trait. - * - * @psalm-param trait-string $traitName - * - * @throws MockObjectException - * - * @deprecated https://github.com/sebastianbergmann/phpunit/issues/5244 - */ - final protected function getObjectForTrait(string $traitName, array $arguments = [], string $traitClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true): object - { - Event\Facade::emitter()->testTriggeredPhpunitDeprecation( - $this->valueObjectForEvents(), - 'getObjectForTrait() is deprecated and will be removed in PHPUnit 12 without replacement.', - ); - - return (new MockGenerator)->objectForTrait( - $traitName, - $traitClassName, - $callAutoload, - $callOriginalConstructor, - $arguments, - ); - } - protected function transformException(Throwable $t): Throwable { return $t; diff --git a/tests/unit/Framework/MockObject/Creation/GetObjectForTraitTest.php b/tests/unit/Framework/MockObject/Creation/GetObjectForTraitTest.php deleted file mode 100644 index 3c90fb3c0ac..00000000000 --- a/tests/unit/Framework/MockObject/Creation/GetObjectForTraitTest.php +++ /dev/null @@ -1,41 +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 PHPUnit\Framework\Attributes\Group; -use PHPUnit\Framework\Attributes\IgnorePhpunitDeprecations; -use PHPUnit\Framework\Attributes\Medium; -use PHPUnit\Framework\Attributes\TestDox; -use PHPUnit\Framework\MockObject\Generator\UnknownTraitException; -use PHPUnit\Framework\TestCase; -use PHPUnit\TestFixture\MockObject\TraitWithConcreteMethod; - -#[Group('test-doubles')] -#[Group('test-doubles/creation')] -#[Medium] -#[TestDox('getObjectForTrait()')] -#[IgnorePhpunitDeprecations] -final class GetObjectForTraitTest extends TestCase -{ - public function testCreatesObjectForTrait(): void - { - $object = $this->getObjectForTrait(TraitWithConcreteMethod::class); - - $this->assertTrue($object->doSomething()); - } - - public function testCannotCreateObjectForTraitThatDoesNotExist(): void - { - $this->expectException(UnknownTraitException::class); - $this->expectExceptionMessage('Trait "TraitThatDoesNotExist" does not exist'); - - $this->getObjectForTrait('TraitThatDoesNotExist'); - } -}