PHPUnit_Util_Test::getDependencies PHP Method

getDependencies() public static method

Returns the dependencies for a test class or method.
public static getDependencies ( string $className, string $methodName ) : array
$className string
$methodName string
return array
    public static function getDependencies($className, $methodName)
    {
        $annotations = self::parseTestMethodAnnotations($className, $methodName);
        $dependencies = [];
        if (isset($annotations['class']['depends'])) {
            $dependencies = $annotations['class']['depends'];
        }
        if (isset($annotations['method']['depends'])) {
            $dependencies = array_merge($dependencies, $annotations['method']['depends']);
        }
        return array_unique($dependencies);
    }

Usage Example

Example #1
0
 /**
  * @constructor
  * @param string $class
  * @param string $name
  * @param string $path
  */
 public function __construct($class = '', $name = '', $path = '')
 {
     $this->initObjectManager();
     if (!$class || !class_exists($class, false)) {
         $this->addTest(self::warning(sprintf('Test Case Class is not valid or empty: "%s"', $class)));
         return;
     }
     if (!$name) {
         $this->addTest(self::warning(sprintf('Test Method Should be set for InjectableMethod class. Test Case Class: %s', $class)));
         return;
     }
     $this->setName($name);
     $arguments = ['class' => $class, 'path' => $path, 'name' => $name];
     $theClass = new \ReflectionClass($class);
     $method = $theClass->getMethod($name);
     if (!$this->isPublicTestMethod($method)) {
         return;
     }
     $methodName = $method->getName();
     $test = self::createTest($theClass, $methodName, $arguments);
     if ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof InjectableMethod) {
         $test->setDependencies(\PHPUnit_Util_Test::getDependencies($class, $methodName));
     }
     $this->addTest($test, \PHPUnit_Util_Test::getGroups($class, $methodName));
     $this->testCase = true;
 }
All Usage Examples Of PHPUnit_Util_Test::getDependencies