Skip to content
Permalink
Browse files

Neither the @errorhandler annotation nor the setUseErrorHandler() met…

…hod {are|were} documented. They also did not (not really, at least) work.

This commit removes support for the @errorhandler annotation and makes setUseErrorHandler() a no-op while deprecating it for removal in PHPUnit 9.
  • Loading branch information...
sebastianbergmann committed Jun 21, 2019
1 parent 07a4e0b commit 3426cfda812934f0c72d3fdc4dceb92ca14686b2
Showing with 4 additions and 59 deletions.
  1. +3 −28 src/Framework/TestCase.php
  2. +1 −22 src/Framework/TestResult.php
  3. +0 −9 src/Util/Test.php
@@ -104,11 +104,6 @@ abstract class TestCase extends Assert implements SelfDescribing, Test
*/
private $dataName;
/**
* @var bool
*/
private $useErrorHandler;
/**
* @var null|string
*/
@@ -645,9 +640,11 @@ public function setRegisterMockObjectsFromTestArgumentsRecursively(bool $flag):
$this->registerMockObjectsFromTestArgumentsRecursively = $flag;
}
/**
* @deprecated Invoking this method has no effect; it will be removed in PHPUnit 9
*/
public function setUseErrorHandler(bool $useErrorHandler): void
{
$this->useErrorHandler = $useErrorHandler;
}
public function getStatus(): int
@@ -693,12 +690,6 @@ public function run(TestResult $result = null): TestResult
if (!$this instanceof WarningTestCase) {
$this->setTestResultObject($result);
$this->setUseErrorHandlerFromAnnotation();
}
if ($this->useErrorHandler !== null) {
$oldErrorHandlerSetting = $result->getConvertErrorsToExceptions();
$result->convertErrorsToExceptions($this->useErrorHandler);
}
if (!$this instanceof WarningTestCase &&
@@ -823,10 +814,6 @@ public function run(TestResult $result = null): TestResult
$result->run($this);
}
if (isset($oldErrorHandlerSetting)) {
$result->convertErrorsToExceptions($oldErrorHandlerSetting);
}
$this->result = null;
return $result;
@@ -1763,18 +1750,6 @@ private function setExpectedExceptionFromAnnotation(): void
}
}
private function setUseErrorHandlerFromAnnotation(): void
{
$useErrorHandler = TestUtil::getErrorHandlerSettings(
\get_class($this),
$this->name
);
if ($useErrorHandler !== null) {
$this->setUseErrorHandler($useErrorHandler);
}
}
/**
* @throws Warning
* @throws SkippedTestError
@@ -97,11 +97,6 @@ final class TestResult implements Countable
*/
private $codeCoverage;
/**
* @var bool
*/
private $registerErrorHandler = true;
/**
* @var bool
*/
@@ -632,7 +627,7 @@ public function run(Test $test): void
$this->startTest($test);
if ($this->registerErrorHandler && ($this->convertDeprecationsToExceptions || $this->convertErrorsToExceptions || $this->convertNoticesToExceptions || $this->convertWarningsToExceptions)) {
if ($this->convertDeprecationsToExceptions || $this->convertErrorsToExceptions || $this->convertNoticesToExceptions || $this->convertWarningsToExceptions) {
$errorHandler = new ErrorHandler(
$this->convertDeprecationsToExceptions,
$this->convertErrorsToExceptions,
@@ -978,22 +973,6 @@ public function setCodeCoverage(CodeCoverage $codeCoverage): void
$this->codeCoverage = $codeCoverage;
}
/**
* Enables or disables the registration of PHPUnit's error handler.
*/
public function registerErrorHandler(bool $flag): void
{
$this->registerErrorHandler = $flag;
}
/**
* Returns whether PHPUnit's error handler is to be registered.
*/
public function getRegisterErrorHandler(): bool
{
return $this->registerErrorHandler;
}
/**
* Enables or disables the deprecation-to-exception conversion.
*/
@@ -699,15 +699,6 @@ public static function getDependencies(string $className, string $methodName): a
return \array_unique($dependencies);
}
public static function getErrorHandlerSettings(string $className, ?string $methodName): ?bool
{
return self::getBooleanAnnotationSetting(
$className,
$methodName,
'errorHandler'
);
}
public static function getGroups(string $className, ?string $methodName = ''): array
{
$annotations = self::parseTestMethodAnnotations(

0 comments on commit 3426cfd

Please sign in to comment.
You can’t perform that action at this time.