diff options
author | jenkins-bot <jenkins-bot@gerrit.wikimedia.org> | 2021-01-13 04:06:55 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@wikimedia.org> | 2021-01-13 04:06:55 +0000 |
commit | 658cb99a4b41f9ce71b75c2ec8964360472b02a3 (patch) | |
tree | ee44126935d2ca566e7fbe99853c5e70c515335a /tests/phpunit/includes/debug/MWDebugTest.php | |
parent | 655b3fbc0472c8014ebbf4fa94be5701c97d1a1f (diff) | |
parent | 8a7d4875450ec39cd50e705c2007c9d1ce55c093 (diff) | |
download | mediawikicore-658cb99a4b41f9ce71b75c2ec8964360472b02a3.tar.gz mediawikicore-658cb99a4b41f9ce71b75c2ec8964360472b02a3.zip |
Merge "Emit deprecation warning for deprecated overrides."
Diffstat (limited to 'tests/phpunit/includes/debug/MWDebugTest.php')
-rw-r--r-- | tests/phpunit/includes/debug/MWDebugTest.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/phpunit/includes/debug/MWDebugTest.php b/tests/phpunit/includes/debug/MWDebugTest.php index 4e7e375b1b66..8734b523548d 100644 --- a/tests/phpunit/includes/debug/MWDebugTest.php +++ b/tests/phpunit/includes/debug/MWDebugTest.php @@ -51,6 +51,42 @@ class MWDebugTest extends MediaWikiIntegrationTestCase { } /** + * @covers MWDebug::detectDeprecatedOverride + */ + public function testDetectDeprecatedOverride() { + $baseclassInstance = new TitleValue( NS_MAIN, 'Test' ); + + $this->assertFalse( + MWDebug::detectDeprecatedOverride( + $baseclassInstance, + TitleValue::class, + 'getNamespace', + MW_VERSION + ) + ); + + // create a dummy subclass that overrides a method + $subclassInstance = new class ( NS_MAIN, 'Test' ) extends TitleValue { + public function getNamespace() { + // never called + return -100; + } + }; + + $this->assertTrue( + MWDebug::detectDeprecatedOverride( + $subclassInstance, + TitleValue::class, + 'getNamespace', + MW_VERSION + ) + ); + + // A warning should have been logged + $this->assertCount( 1, MWDebug::getLog() ); + } + + /** * @covers MWDebug::deprecated */ public function testAvoidDuplicateDeprecations() { |