aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/unit/includes/config/EtcdConfigTest.php
diff options
context:
space:
mode:
authorDaimona Eaytoy <daimona.wiki@gmail.com>2024-02-23 20:15:11 +0100
committerDaimona Eaytoy <daimona.wiki@gmail.com>2024-02-23 22:09:45 +0100
commit89f583625a3479ee1ba917307fe2d729a00816d7 (patch)
tree36e38cdca4de6258f2c3bc7d3f828ed5b9b56d12 /tests/phpunit/unit/includes/config/EtcdConfigTest.php
parent0ea2c78b1b58950aa98ca84184596c49ddea5537 (diff)
downloadmediawikicore-89f583625a3479ee1ba917307fe2d729a00816d7.tar.gz
mediawikicore-89f583625a3479ee1ba917307fe2d729a00816d7.zip
tests: Add replacement for assertions deprecated in PHPUnit 9.6
expectWarning() and friends have been deprecated in PHPUnit 9.6, and removed in PHPUnit 10. Unfortunately, there is no simple replacement because PHPUnit no longer converts them to exceptions in the first place. In fact, Sebastian Bergmann explicitly stated that he does not consider the use case of > a library developer to verify a code block warns its consumer when > certain action is performed worth supporting. So, add an ad-hoc replacement for all the deprecated methods. This is quite ugly, but it's simple enough given the low number of usages. On the bright side, this new method does not halt the test when the warning is triggered. This seems to align with the developers' expectation, seen in a few existing tests, that any code following the notice will be executed. Bug: T342110 Change-Id: I214abfed4280834840c115777ed78eb0a5570da9
Diffstat (limited to 'tests/phpunit/unit/includes/config/EtcdConfigTest.php')
-rw-r--r--tests/phpunit/unit/includes/config/EtcdConfigTest.php10
1 files changed, 7 insertions, 3 deletions
diff --git a/tests/phpunit/unit/includes/config/EtcdConfigTest.php b/tests/phpunit/unit/includes/config/EtcdConfigTest.php
index 73f35b6d6be7..1909f320cb82 100644
--- a/tests/phpunit/unit/includes/config/EtcdConfigTest.php
+++ b/tests/phpunit/unit/includes/config/EtcdConfigTest.php
@@ -360,9 +360,13 @@ class EtcdConfigTest extends MediaWikiUnitTestCase {
public function testLoadCacheExpiredNoLockWarning() {
$mock = $this->createConfigMockWithNoLock();
- $this->expectNotice();
- $this->expectNoticeMessage( 'using stale data: lost lock' );
- $mock->get( 'known' );
+ $this->expectPHPError(
+ E_USER_NOTICE,
+ static function () use ( $mock ) {
+ $mock->get( 'known' );
+ },
+ 'using stale data: lost lock'
+ );
}
public static function provideFetchFromServer() {