Skip to content

Commit

Permalink
TASK: Deprecate BaseTestCase functionalities
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Feb 5, 2024
1 parent ecfe3ed commit 98a5829
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
7 changes: 4 additions & 3 deletions Neos.Flow/Tests/AccessibleProxyInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@
*
* Note that this interface is not actually implemented by the accessible proxy, but only provides IDE support.
*
* @deprecated you should not use this for unit testing
* @deprecated you should not use this for testing. As it will couple the tests to highly to the internal implementation
* and makes refactorings without rewriting major tests impossible.
*/
interface AccessibleProxyInterface
{
/** @deprecated */
public function _call(string $methodName, mixed ...$arguments): mixed;
/** @deprecated */
public function _callRef(string $methodName, mixed ...$argumentsPassedByReference): mixed;
/** @deprecated please use {@see BaseTestCase::inject()} instead */
/** @deprecated please specify properties via constructor call the injector manually or use - if you must - {@see ObjectAccess::setProperty()} instead. */
public function _set(string $propertyName, mixed $value): void;
/** @deprecated */
public function _setRef(string $propertyName, mixed &$value): void;
/** @deprecated please use {@see ObjectAccess::getProperty()} instead */
/** @deprecated please use - if you must - {@see ObjectAccess::setProperty()} instead. */
public function _get(string $propertyName): mixed;
}
14 changes: 5 additions & 9 deletions Neos.Flow/Tests/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@
* Don't sub class this test case but rather choose a more specialized base test case,
* such as UnitTestCase or FunctionalTestCase
*
* @api
* @deprecated its utilities are deprecated.
*/
abstract class BaseTestCase extends \PHPUnit\Framework\TestCase
{
/**
* @var array
*/
protected $backupGlobalsBlacklist = ['GLOBALS', 'bootstrap', '__PHPUNIT_BOOTSTRAP'];
protected $backupGlobalsExcludeList = ['GLOBALS', 'bootstrap', '__PHPUNIT_BOOTSTRAP'];

/**
* Enable or disable the backup and restoration of static attributes.
*
* @var boolean
*/
protected $backupStaticAttributes = false;
Expand Down Expand Up @@ -164,13 +162,11 @@ public function _get($propertyName) {
* @return void
* @throws \RuntimeException
* @throws \InvalidArgumentException
* @deprecated please specify properties via constructor, call the injector manually or use - if you must - ObjectAccess::setProperty instead.
*/
protected function inject($target, $name, $dependency)
protected function inject(object $target, string $name, mixed $dependency)
{
if (!is_object($target)) {
throw new \InvalidArgumentException('Wrong type for argument $target, must be object.');
}

// we don't use ObjectAccess::setProperty as it doesn't support `inject*`
$objectReflection = new \ReflectionObject($target);
$methodNamePart = strtoupper($name[0]) . substr($name, 1);
if ($objectReflection->hasMethod('set' . $methodNamePart)) {
Expand Down

0 comments on commit 98a5829

Please sign in to comment.