Skip to content

Commit

Permalink
Closes #5250
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Oct 6, 2024
1 parent 9edff8d commit 769cf22
Show file tree
Hide file tree
Showing 9 changed files with 1 addition and 219 deletions.
1 change: 1 addition & 0 deletions ChangeLog-12.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes of the PHPUnit 12.0 release series are documented in this fi

* [#5247](https://github.com/sebastianbergmann/phpunit/issues/5247): `TestCase::getMockForAbstractClass()`
* [#5249](https://github.com/sebastianbergmann/phpunit/issues/5249): `TestCase::getMockForTrait()`
* [#5250](https://github.com/sebastianbergmann/phpunit/issues/5250): `TestCase::getObjectForTrait()`
* [#5313](https://github.com/sebastianbergmann/phpunit/issues/5313): `MockBuilder::getMockForTrait()`
* [#5314](https://github.com/sebastianbergmann/phpunit/issues/5314): `MockBuilder::getMockForAbstractClass()`
* [#5978](https://github.com/sebastianbergmann/phpunit/issues/5978): Support for PHP 8.2
Expand Down
1 change: 0 additions & 1 deletion DEPRECATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ This functionality is currently [hard-deprecated](https://phpunit.de/backward-co
|-------------------------------------------------------------------|--------------------------------------------------------------------------------|--------|-----------------------------------------------------------------------------------------|
| [#5240](https://github.com/sebastianbergmann/phpunit/issues/5240) | `TestCase::createTestProxy()` | 10.1.0 | |
| [#5242](https://github.com/sebastianbergmann/phpunit/issues/5242) | `TestCase::getMockFromWsdl()` | 10.1.0 | |
| [#5244](https://github.com/sebastianbergmann/phpunit/issues/5244) | `TestCase::getObjectForTrait()` | 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 | |
| [#5307](https://github.com/sebastianbergmann/phpunit/issues/5307) | `MockBuilder::setProxyTarget()` | 10.1.0 | |
Expand Down

This file was deleted.

45 changes: 0 additions & 45 deletions src/Framework/MockObject/Generator/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,51 +233,6 @@ public function testDoubleForInterfaceIntersection(array $interfaces, bool $mock
);
}

/**
* Returns an object for the specified trait.
*
* @param trait-string $traitName
* @param list<mixed> $arguments
*
* @throws ReflectionException
* @throws RuntimeException
* @throws UnknownTraitException
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/5244
*/
public function objectForTrait(string $traitName, string $traitClassName = '', bool $callAutoload = true, bool $callOriginalConstructor = false, array $arguments = []): object
{
if (!trait_exists($traitName, $callAutoload)) {
throw new UnknownTraitException($traitName);
}

$className = $this->generateClassName(
$traitName,
$traitClassName,
'Trait_',
);

$classTemplate = $this->loadTemplate('trait_class.tpl');

$classTemplate->setVar(
[
'prologue' => '',
'class_name' => $className['className'],
'trait_name' => $traitName,
],
);

return $this->getObject(
new MockTrait(
$classTemplate->render(),
$className['className'],
),
'',
$callOriginalConstructor,
$arguments,
);
}

/**
* @param ?list<non-empty-string> $methods
*
Expand Down
50 changes: 0 additions & 50 deletions src/Framework/MockObject/Generator/MockTrait.php

This file was deleted.

6 changes: 0 additions & 6 deletions src/Framework/MockObject/Generator/templates/trait_class.tpl

This file was deleted.

26 changes: 0 additions & 26 deletions src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1539,32 +1539,6 @@ final protected function getMockFromWsdl(string $wsdlFile, string $originalClass
return $mockObject;
}

/**
* Creates an object that uses the specified trait.
*
* @param trait-string $traitName
* @param array<mixed> $arguments
*
* @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;
Expand Down
18 changes: 0 additions & 18 deletions tests/_files/mock-object/TraitWithConcreteMethod.php

This file was deleted.

41 changes: 0 additions & 41 deletions tests/unit/Framework/MockObject/Creation/GetObjectForTraitTest.php

This file was deleted.

0 comments on commit 769cf22

Please sign in to comment.