Skip to content

Commit

Permalink
Fix sebastianbergmann#1351: Add back TestFailure::failedTest() for BC.
Browse files Browse the repository at this point in the history
  • Loading branch information
sun committed Jul 27, 2014
1 parent b617a1f commit 5ca9d55
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,15 @@ public function setInIsolation($inIsolation)
}
}

/**
* @return boolean
* @since Method available since Release 4.1.5
*/
public function isInIsolation()
{
return !empty($this->inIsolation);
}

/**
* @return mixed
* @since Method available since Release 3.4.0
Expand Down
23 changes: 23 additions & 0 deletions src/Framework/TestFailure.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class PHPUnit_Framework_TestFailure
*/
private $testName;

/**
* @var PHPUnit_Framework_Test|null
*/
protected $failedTest;

/**
* @var Exception
*/
Expand All @@ -79,6 +84,9 @@ public function __construct(PHPUnit_Framework_Test $failedTest, Exception $throw
} else {
$this->testName = get_class($failedTest);
}
if (!$failedTest instanceof PHPUnit_Framework_TestCase || !$failedTest->isInIsolation()) {
$this->failedTest = $failedTest;
}
$this->thrownException = $thrownException;
}

Expand Down Expand Up @@ -147,6 +155,21 @@ public function getTestName()
return $this->testName;
}

/**
* Returns the failing test.
*
* Note: The test object is not set when the test is executed in process
* isolation.
*
* @see PHPUnit_Framework_Exception
*
* @return PHPUnit_Framework_Test|null
*/
public function failedTest()
{
return $this->failedTest;
}

/**
* Gets the thrown exception.
*
Expand Down

0 comments on commit 5ca9d55

Please sign in to comment.