You are here

protected function PHPUnit_Framework_TestCase::handleDependencies in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/src/Framework/TestCase.php \PHPUnit_Framework_TestCase::handleDependencies()

@since Method available since Release 3.5.4

1 call to PHPUnit_Framework_TestCase::handleDependencies()
PHPUnit_Framework_TestCase::run in vendor/phpunit/phpunit/src/Framework/TestCase.php
Runs the test case and collects the results in a TestResult object. If no TestResult object is passed a new one will be created.

File

vendor/phpunit/phpunit/src/Framework/TestCase.php, line 1739

Class

PHPUnit_Framework_TestCase
A TestCase defines the fixture to run multiple tests.

Code

protected function handleDependencies() {
  if (!empty($this->dependencies) && !$this->inIsolation) {
    $className = get_class($this);
    $passed = $this->result
      ->passed();
    $passedKeys = array_keys($passed);
    $numKeys = count($passedKeys);
    for ($i = 0; $i < $numKeys; $i++) {
      $pos = strpos($passedKeys[$i], ' with data set');
      if ($pos !== false) {
        $passedKeys[$i] = substr($passedKeys[$i], 0, $pos);
      }
    }
    $passedKeys = array_flip(array_unique($passedKeys));
    foreach ($this->dependencies as $dependency) {
      if (strpos($dependency, '::') === false) {
        $dependency = $className . '::' . $dependency;
      }
      if (!isset($passedKeys[$dependency])) {
        $this->result
          ->addError($this, new PHPUnit_Framework_SkippedTestError(sprintf('This test depends on "%s" to pass.', $dependency)), 0);
        return false;
      }
      if (isset($passed[$dependency])) {
        if ($passed[$dependency]['size'] != PHPUnit_Util_Test::UNKNOWN && $this
          ->getSize() != PHPUnit_Util_Test::UNKNOWN && $passed[$dependency]['size'] > $this
          ->getSize()) {
          $this->result
            ->addError($this, new PHPUnit_Framework_SkippedTestError('This test depends on a test that is larger than itself.'), 0);
          return false;
        }
        $this->dependencyInput[$dependency] = $passed[$dependency]['result'];
      }
      else {
        $this->dependencyInput[$dependency] = null;
      }
    }
  }
  return true;
}