From 592b6abc64bd4dcd1d45b1f78070976a7c2e7d09 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sat, 14 Nov 2026 15:06:51 +0100 Subject: [PATCH] [PHPUnit60] Count expectUserDeprecationMessage() as assert in AddDoesNotPerformAssertionToNonAssertingTestRector Extracted from #822. Co-authored-by: bjorn --- ...ip_expect_user_deprecation_message.php.inc | 20 +++++++++++++++++++ src/NodeAnalyzer/AssertCallAnalyzer.php | 1 + 2 files changed, 21 insertions(+) create mode 100644 rules-tests/PHPUnit60/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/skip_expect_user_deprecation_message.php.inc diff --git a/rules-tests/PHPUnit60/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/skip_expect_user_deprecation_message.php.inc b/rules-tests/PHPUnit60/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/skip_expect_user_deprecation_message.php.inc new file mode 100644 index 00000000..2988384c --- /dev/null +++ b/rules-tests/PHPUnit60/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector/Fixture/skip_expect_user_deprecation_message.php.inc @@ -0,0 +1,20 @@ +expectUserDeprecationMessage('Since foo 1.0: Bar is deprecated.'); + + @trigger_error('Since foo 1.0: Bar is deprecated.', E_USER_DEPRECATED); + } + + public function testExpectUserDeprecationMessageMatches() + { + $this->expectUserDeprecationMessageMatches('#^Since foo 1\.0#'); + + @trigger_error('Since foo 1.0: Bar is deprecated.', E_USER_DEPRECATED); + } +} diff --git a/src/NodeAnalyzer/AssertCallAnalyzer.php b/src/NodeAnalyzer/AssertCallAnalyzer.php index 02db1f97..b76e212c 100644 --- a/src/NodeAnalyzer/AssertCallAnalyzer.php +++ b/src/NodeAnalyzer/AssertCallAnalyzer.php @@ -36,6 +36,7 @@ final class AssertCallAnalyzer 'expectException', 'setExpectedException', 'expectOutput', + 'expectUserDeprecationMessage', 'should', ];