[TASK] Duplicate method in base tests 72/27272/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Sun, 2 Feb 2014 18:43:28 +0000 (19:43 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 2 Feb 2014 18:52:37 +0000 (19:52 +0100)
extbase BaseTestCase extends core BaseTestCase and overrides
inject() with a duplicate. Remove dupe.

Change-Id: I96ce01c9754ce57cb5d10e9a322a8c5acb950647
Resolves: #55606
Releases: 6.2
Reviewed-on: https://review.typo3.org/27272
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/extbase/Tests/Unit/BaseTestCase.php

index b9eff7b..2d035ca 100644 (file)
@@ -48,39 +48,4 @@ abstract class BaseTestCase extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->objectManager = clone $objectManager;
                parent::runBare();
        }
-
-       /**
-        * Injects $dependency into property $name of $target
-        *
-        * This is a convenience method for setting a protected or private property in
-        * a test subject for the purpose of injecting a dependency.
-        *
-        * @param object $target The instance which needs the dependency
-        * @param string $name Name of the property to be injected
-        * @param object $dependency The dependency to inject – usually an object but can also be any other type
-        * @return void
-        * @throws \RuntimeException
-        * @throws \InvalidArgumentException
-        */
-       protected function inject($target, $name, $dependency) {
-               if (!is_object($target)) {
-                       throw new \InvalidArgumentException('Wrong type for argument $target, must be object.');
-               }
-
-               $objectReflection = new \ReflectionObject($target);
-               $methodNamePart = strtoupper($name[0]) . substr($name, 1);
-               if ($objectReflection->hasMethod('set' . $methodNamePart)) {
-                       $methodName = 'set' . $methodNamePart;
-                       $target->$methodName($dependency);
-               } elseif ($objectReflection->hasMethod('inject' . $methodNamePart)) {
-                       $methodName = 'inject' . $methodNamePart;
-                       $target->$methodName($dependency);
-               } elseif ($objectReflection->hasProperty($name)) {
-                       $property = $objectReflection->getProperty($name);
-                       $property->setAccessible(TRUE);
-                       $property->setValue($target, $dependency);
-               } else {
-                       throw new \RuntimeException('Could not inject ' . $name . ' into object of type ' . get_class($target));
-               }
-       }
 }