| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Tests\Maintenance; |
| 4 |
|
| 5 |
use FindDeprecated; |
| 6 |
use Wikimedia\TestingAccessWrapper; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 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 |
|
| 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 |
|
| 37 |
|
| 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 |
} |