Skip to content
Browse files

Refactor.

  • Loading branch information...
1 parent b487628 commit c41f8d696b1c4f6e653b25479ef01ce796d59be2 @sebastianbergmann committed Oct 29, 2010
Showing with 55 additions and 43 deletions.
  1. +55 −43 PHPUnit/Framework/TestCase.php
View
98 PHPUnit/Framework/TestCase.php
@@ -491,6 +491,8 @@ public function run(PHPUnit_Framework_TestResult $result = NULL)
$result = $this->createResult();
}
+ $this->result = $result;
+
$this->setExpectedExceptionFromAnnotation();
$this->setUseErrorHandlerFromAnnotation();
$this->setUseOutputBufferingFromAnnotation();
@@ -500,49 +502,8 @@ public function run(PHPUnit_Framework_TestResult $result = NULL)
$result->convertErrorsToExceptions($this->useErrorHandler);
}
- $this->result = $result;
-
- 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])) {
- $result->addError(
- $this,
- new PHPUnit_Framework_SkippedTestError(
- sprintf(
- 'This test depends on "%s" to pass.', $dependency
- )
- ),
- 0
- );
-
- return;
- } else {
- if (isset($passed[$dependency])) {
- $this->dependencyInput[] = $passed[$dependency];
- } else {
- $this->dependencyInput[] = NULL;
- }
- }
- }
+ if (!$this->handleDependencies()) {
+ return;
}
if ($this->runTestInSeparateProcess === TRUE &&
@@ -1410,6 +1371,57 @@ protected function createResult()
}
/**
+ * @since Method available since Release 3.5.4
+ */
+ 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;
+ } else {
+ if (isset($passed[$dependency])) {
+ $this->dependencyInput[] = $passed[$dependency];
+ } else {
+ $this->dependencyInput[] = NULL;
+ }
+ }
+ }
+ }
+
+ return TRUE;
+ }
+
+ /**
* This method is called before the first test of this test class is run.
*
* @since Method available since Release 3.4.0

0 comments on commit c41f8d6

Please sign in to comment.
Something went wrong with that request. Please try again.