Skip to content

Commit

Permalink
Closes #3777
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Dec 13, 2020
1 parent baa0cce commit cc5afae
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .psalm/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@
<code>$matches</code>
</MissingClosureParamType>
</file>
<file src="src/Util/ErrorHandler.php">
<file src="src/Util/Error/Handler.php">
<InvalidArgument occurrences="1"/>
<MissingClosureParamType occurrences="2">
<code>$errorNumber</code>
Expand Down
1 change: 1 addition & 0 deletions ChangeLog-10.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ All notable changes of the PHPUnit 10.0 release series are documented in this fi
### Removed

* [#3769](https://github.com/sebastianbergmann/phpunit/issues/3769): Remove `MockBuilder::setMethods()` and `MockBuilder::setMethodsExcept()`
* [#3777](https://github.com/sebastianbergmann/phpunit/issues/3777): Remove `PHPUnit\Framework\Error\*` classes
* [#3870](https://github.com/sebastianbergmann/phpunit/issues/3870): Drop support for PHP 7.3
* [#4063](https://github.com/sebastianbergmann/phpunit/issues/4063): Remove `assertNotIsReadable()`
* [#4066](https://github.com/sebastianbergmann/phpunit/issues/4066): Remove `assertNotIsWritable()`
Expand Down
34 changes: 5 additions & 29 deletions src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@
use PHPUnit\Framework\Constraint\ExceptionCode;
use PHPUnit\Framework\Constraint\ExceptionMessage;
use PHPUnit\Framework\Constraint\ExceptionMessageRegularExpression;
use PHPUnit\Framework\Error\Deprecated;
use PHPUnit\Framework\Error\Error;
use PHPUnit\Framework\Error\Notice;
use PHPUnit\Framework\Error\Warning as WarningError;
use PHPUnit\Framework\MockObject\Generator as MockGenerator;
use PHPUnit\Framework\MockObject\MockBuilder;
use PHPUnit\Framework\MockObject\MockObject;
Expand All @@ -86,6 +82,10 @@
use PHPUnit\Framework\MockObject\Stub\ReturnValueMap as ReturnValueMapStub;
use PHPUnit\Runner\BaseTestRunner;
use PHPUnit\Runner\PhptTestCase;
use PHPUnit\Util\Error\Deprecation;
use PHPUnit\Util\Error\Error;
use PHPUnit\Util\Error\Notice;
use PHPUnit\Util\Error\Warning as WarningError;
use PHPUnit\Util\Exception as UtilException;
use PHPUnit\Util\GlobalState;
use PHPUnit\Util\PHP\AbstractPhpProcess;
Expand Down Expand Up @@ -451,30 +451,6 @@ public function expectOutputString(string $expectedString): void
*/
public function expectException(string $exception): void
{
// @codeCoverageIgnoreStart
switch ($exception) {
case Deprecated::class:
$this->addWarning('Support for using expectException() with PHPUnit\Framework\Error\Deprecated is deprecated and will be removed in PHPUnit 10. Use expectDeprecation() instead.');

break;

case Error::class:
$this->addWarning('Support for using expectException() with PHPUnit\Framework\Error\Error is deprecated and will be removed in PHPUnit 10. Use expectError() instead.');

break;

case Notice::class:
$this->addWarning('Support for using expectException() with PHPUnit\Framework\Error\Notice is deprecated and will be removed in PHPUnit 10. Use expectNotice() instead.');

break;

case WarningError::class:
$this->addWarning('Support for using expectException() with PHPUnit\Framework\Error\Warning is deprecated and will be removed in PHPUnit 10. Use expectWarning() instead.');

break;
}
// @codeCoverageIgnoreEnd

$this->expectedException = $exception;
}

Expand Down Expand Up @@ -515,7 +491,7 @@ public function expectNotToPerformAssertions(): void

public function expectDeprecation(): void
{
$this->expectedException = Deprecated::class;
$this->expectedException = Deprecation::class;
}

public function expectDeprecationMessage(string $message): void
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/TestFailure.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use function get_class;
use function sprintf;
use function trim;
use PHPUnit\Framework\Error\Error;
use PHPUnit\Util\Error\Error;
use Throwable;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Framework/TestResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use AssertionError;
use Countable;
use Error;
use PHPUnit\Util\ErrorHandler;
use PHPUnit\Util\Error\Handler;
use PHPUnit\Util\ExcludeList;
use PHPUnit\Util\Printer;
use PHPUnit\Util\Test as TestUtil;
Expand Down Expand Up @@ -571,7 +571,7 @@ public function run(Test $test): void
$this->startTest($test);

if ($this->convertDeprecationsToExceptions || $this->convertErrorsToExceptions || $this->convertNoticesToExceptions || $this->convertWarningsToExceptions) {
$errorHandler = new ErrorHandler(
$errorHandler = new Handler(
$this->convertDeprecationsToExceptions,
$this->convertErrorsToExceptions,
$this->convertNoticesToExceptions,
Expand Down
4 changes: 2 additions & 2 deletions src/Runner/DefaultTestResultCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use function serialize;
use function sprintf;
use function unserialize;
use PHPUnit\Util\ErrorHandler;
use PHPUnit\Util\Error\Handler;
use PHPUnit\Util\Filesystem;
use Serializable;

Expand Down Expand Up @@ -161,7 +161,7 @@ public function load(): void
}
// @codeCoverageIgnoreEnd

$cache = ErrorHandler::invokeIgnoringWarnings(
$cache = Handler::invokeIgnoringWarnings(
static function () use ($cacheData) {
return @unserialize($cacheData, ['allowed_classes' => [self::class]]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\Error;
namespace PHPUnit\Util\Error;

/**
* @internal
*/
final class Deprecated extends Error
final class Deprecation extends Error
{
}
2 changes: 1 addition & 1 deletion src/Framework/Error/Error.php → src/Util/Error/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\Error;
namespace PHPUnit\Util\Error;

use PHPUnit\Framework\Exception;

Expand Down
10 changes: 3 additions & 7 deletions src/Util/ErrorHandler.php → src/Util/Error/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Util;
namespace PHPUnit\Util\Error;

use const E_DEPRECATED;
use const E_NOTICE;
Expand All @@ -19,15 +19,11 @@
use function error_reporting;
use function restore_error_handler;
use function set_error_handler;
use PHPUnit\Framework\Error\Deprecated;
use PHPUnit\Framework\Error\Error;
use PHPUnit\Framework\Error\Notice;
use PHPUnit\Framework\Error\Warning;

/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final class ErrorHandler
final class Handler
{
private bool $convertDeprecationsToExceptions;

Expand Down Expand Up @@ -101,7 +97,7 @@ public function __invoke(int $errorNumber, string $errorString, string $errorFil
return false;
}

throw new Deprecated($errorString, $errorNumber, $errorFile, $errorLine);
throw new Deprecation($errorString, $errorNumber, $errorFile, $errorLine);

default:
if (!$this->convertErrorsToExceptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\Error;
namespace PHPUnit\Util\Error;

/**
* @internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\Error;
namespace PHPUnit\Util\Error;

/**
* @internal
Expand Down
3 changes: 2 additions & 1 deletion src/Util/RegularExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace PHPUnit\Util;

use function preg_match;
use PHPUnit\Util\Error\Handler;

/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
Expand All @@ -21,7 +22,7 @@ final class RegularExpression
*/
public static function safeMatch(string $pattern, string $subject)
{
return ErrorHandler::invokeIgnoringWarnings(
return Handler::invokeIgnoringWarnings(
static function () use ($pattern, $subject) {
return preg_match($pattern, $subject);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Framework/TestFailureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*/
namespace PHPUnit\Framework;

use PHPUnit\Framework\Error\Error;
use PHPUnit\TestFixture\NotSelfDescribingTest;
use PHPUnit\Util\Error\Error;
use SebastianBergmann\Comparator\ComparisonFailure;

/**
Expand Down

0 comments on commit cc5afae

Please sign in to comment.