From a07c36460862bdd823dc4c47fa959c20a72aec43 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Mon, 30 Mar 2020 09:11:53 +0200 Subject: [PATCH] Closes #4133 --- ChangeLog-8.5.md | 1 + src/Framework/TestCase.php | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog-8.5.md b/ChangeLog-8.5.md index dd4e4c1bace..7a0673e015e 100644 --- a/ChangeLog-8.5.md +++ b/ChangeLog-8.5.md @@ -7,6 +7,7 @@ All notable changes of the PHPUnit 8.5 release series are documented in this fil ### Fixed * [#4017](https://github.com/sebastianbergmann/phpunit/issues/4017): Do not suggest refactoring to something that is also deprecated +* [#4133](https://github.com/sebastianbergmann/phpunit/issues/4133): `expectExceptionMessageRegExp()` has been removed in PHPUnit 9 without a deprecation warning being given in PHPUnit 8 * [#4139](https://github.com/sebastianbergmann/phpunit/issues/4139): Cannot double interfaces that declare a constructor with PHP 8 * [#4144](https://github.com/sebastianbergmann/phpunit/issues/4144): Empty objects are converted to empty arrays in JSON comparison failure diff diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php index e46a6d4638c..de79be048fe 100644 --- a/src/Framework/TestCase.php +++ b/src/Framework/TestCase.php @@ -269,6 +269,11 @@ abstract class TestCase extends Assert implements SelfDescribing, Test */ private $doubledTypes = []; + /** + * @var bool + */ + private $deprecatedExpectExceptionMessageRegExpUsed = false; + /** * Returns a matcher that matches when the method is executed * zero or more times. @@ -506,6 +511,8 @@ public function expectExceptionMessageMatches(string $regularExpression): void */ public function expectExceptionMessageRegExp(string $regularExpression): void { + $this->deprecatedExpectExceptionMessageRegExpUsed = true; + $this->expectExceptionMessageMatches($regularExpression); } @@ -1447,6 +1454,10 @@ protected function runTest() ); } + if ($this->deprecatedExpectExceptionMessageRegExpUsed) { + $this->addWarning('expectExceptionMessageRegExp() is deprecated in PHPUnit 8 and will be removed in PHPUnit 9.'); + } + return; }