diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php index ac6f087e9cf..d450d521bb8 100755 --- a/src/Framework/TestCase.php +++ b/src/Framework/TestCase.php @@ -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 diff --git a/src/Framework/TestFailure.php b/src/Framework/TestFailure.php index 835ea91cad5..4ea38415545 100644 --- a/src/Framework/TestFailure.php +++ b/src/Framework/TestFailure.php @@ -61,6 +61,11 @@ class PHPUnit_Framework_TestFailure */ private $testName; + /** + * @var PHPUnit_Framework_Test|null + */ + protected $failedTest; + /** * @var Exception */ @@ -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; } @@ -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. *