3 namespace MediaWiki\Tests\Maintenance
;
6 use Wikimedia\TestingAccessWrapper
;
9 * @covers \FindDeprecated
10 * @covers \DeprecatedInterfaceFinder
11 * @covers \FileAwareNodeVisitor
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' ] )
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' )
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' ) . "/"