Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / maintenance / FindDeprecatedTest.php
blob28a9eb19c3a143ba6fbc2c5d0ef159b00e4c6074
1 <?php
3 namespace MediaWiki\Tests\Maintenance;
5 use FindDeprecated;
6 use Wikimedia\TestingAccessWrapper;
8 /**
9 * @covers \FindDeprecated
10 * @covers \DeprecatedInterfaceFinder
11 * @covers \FileAwareNodeVisitor
12 * @group Database
13 * @author Dreamy Jazz
15 class FindDeprecatedTest extends MaintenanceBaseTestCase {
17 private const FIXTURE_DIRECTORY = MW_INSTALL_PATH . '/tests/phpunit/data/FindDeprecated';
19 protected function getMaintenanceClass() {
20 return FindDeprecated::class;
23 protected function createMaintenance() {
24 // Mock ::getMwInstallPath to return our mock path
25 $obj = $this->getMockBuilder( $this->getMaintenanceClass() )
26 ->onlyMethods( [ 'getMwInstallPath' ] )
27 ->getMock();
28 $obj->method( 'getMwInstallPath' )
29 ->willReturn( self::FIXTURE_DIRECTORY );
30 return TestingAccessWrapper::newFromObject( $obj );
33 public function testExecute() {
34 // Creation of dynamic property is deprecated which is done by the script being tested.
35 // FIXME: Make this test work in PHP 8.2 and above.
36 $this->markTestSkippedIfPhp( '>=', '8.2' );
38 $this->maintenance->execute();
39 $this->expectOutputRegex(
40 "/Deprecated since 1.42:\n.*" . preg_quote( '+ FileWithDeprecatedCodeInSubDirectory::testMethodOne' )
41 . "[\s\S]*" .
42 "Deprecated since 1.43:\n.*" . preg_quote( '- FileWithDeprecatedCode::testMethodOne' ) . "[\s\S]*" .
43 "Deprecated since 1.44:\n.*" . preg_quote( '+ FileWithDeprecatedCode::testMethodTwo' ) . "[\s\S]*" .
44 "legend:\n.*-: soft-deprecated\n.*" . preg_quote( '+: hard-deprecated' ) . "/"