Debian Codegraph @

tests/phpunit/maintenance/FindDeprecatedTest.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Tests\Maintenance;
4
5 use FindDeprecated;
6 use Wikimedia\TestingAccessWrapper;
7
8 /**
9 * Tests that a XML file exported by {@link ExportSites} can be imported by {@link ImportSites}.
10 *
11 * @covers FindDeprecated
12 * @covers DeprecatedInterfaceFinder
13 * @covers FileAwareNodeVisitor
14 * @group Database
15 * @author Dreamy Jazz
16 */
17 class FindDeprecatedTest extends MaintenanceBaseTestCase {
18
19 private const FIXTURE_DIRECTORY = MW_INSTALL_PATH . '/tests/phpunit/data/FindDeprecated';
20
21 protected function getMaintenanceClass() {
22 return FindDeprecated::class;
23 }
24
25 protected function createMaintenance() {
26 // Mock ::getMwInstallPath to return our mock path
27 $obj = $this->getMockBuilder( $this->getMaintenanceClass() )
28 ->onlyMethods( [ 'getMwInstallPath' ] )
29 ->getMock();
30 $obj->method( 'getMwInstallPath' )
31 ->willReturn( self::FIXTURE_DIRECTORY );
32 return TestingAccessWrapper::newFromObject( $obj );
33 }
34
35 public function testExecute() {
36 // Creation of dynamic property is deprecated which is done by the script being tested.
37 // FIXME: Make this test work in PHP 8.2 and above.
38 $this->markTestSkippedIfPhp( '>=', '8.2' );
39
40 $this->maintenance->execute();
41 $this->expectOutputRegex(
42 "/Deprecated since 1.42:\n.*" . preg_quote( '+ FileWithDeprecatedCodeInSubDirectory::testMethodOne' )
43 . "[\s\S]*" .
44 "Deprecated since 1.43:\n.*" . preg_quote( '- FileWithDeprecatedCode::testMethodOne' ) . "[\s\S]*" .
45 "Deprecated since 1.44:\n.*" . preg_quote( '+ FileWithDeprecatedCode::testMethodTwo' ) . "[\s\S]*" .
46 "legend:\n.*-: soft-deprecated\n.*" . preg_quote( '+: hard-deprecated' ) . "/"
47 );
48 }
49 }