This is moderately messy. Process was principally: * xargs rg --files-with-matches '^use Title;' | grep 'php$' | \ xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1' * rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \ xargs rg --files-with-matches 'Title\b' | \ xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1' * composer fix Then manual fix-ups for a few files that don't have any use statements. Bug: T166010 Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
83 lines
1.8 KiB
PHP
83 lines
1.8 KiB
PHP
<?php
|
|
|
|
use MediaWiki\Title\Title;
|
|
|
|
/**
|
|
* Basic tests for Parser::getPreloadText
|
|
* @author Antoine Musso
|
|
*
|
|
* @covers Parser
|
|
* @covers StripState
|
|
*
|
|
* @covers Preprocessor_Hash
|
|
* @covers PPDStack_Hash
|
|
* @covers PPDStackElement_Hash
|
|
* @covers PPDPart_Hash
|
|
* @covers PPFrame_Hash
|
|
* @covers PPTemplateFrame_Hash
|
|
* @covers PPCustomFrame_Hash
|
|
* @covers PPNode_Hash_Tree
|
|
* @covers PPNode_Hash_Text
|
|
* @covers PPNode_Hash_Array
|
|
* @covers PPNode_Hash_Attr
|
|
*/
|
|
class ParserPreloadTest extends MediaWikiIntegrationTestCase {
|
|
/**
|
|
* @var Parser
|
|
*/
|
|
private $testParser;
|
|
/**
|
|
* @var ParserOptions
|
|
*/
|
|
private $testParserOptions;
|
|
/**
|
|
* @var Title
|
|
*/
|
|
private $title;
|
|
|
|
protected function setUp(): void {
|
|
parent::setUp();
|
|
$services = $this->getServiceContainer();
|
|
|
|
$this->testParserOptions = ParserOptions::newFromUserAndLang( new User,
|
|
$this->getServiceContainer()->getContentLanguage() );
|
|
|
|
$this->testParser = $services->getParserFactory()->create();
|
|
$this->testParser->setOptions( $this->testParserOptions );
|
|
$this->testParser->clearState();
|
|
|
|
$this->title = Title::makeTitle( NS_MAIN, 'Preload Test' );
|
|
}
|
|
|
|
public function testPreloadSimpleText() {
|
|
$this->assertPreloaded( 'simple', 'simple' );
|
|
}
|
|
|
|
public function testPreloadedPreIsUnstripped() {
|
|
$this->assertPreloaded(
|
|
'<pre>monospaced</pre>',
|
|
'<pre>monospaced</pre>',
|
|
'<pre> in preloaded text must be unstripped (T29467)'
|
|
);
|
|
}
|
|
|
|
public function testPreloadedNowikiIsUnstripped() {
|
|
$this->assertPreloaded(
|
|
'<nowiki>[[Dummy title]]</nowiki>',
|
|
'<nowiki>[[Dummy title]]</nowiki>',
|
|
'<nowiki> in preloaded text must be unstripped (T29467)'
|
|
);
|
|
}
|
|
|
|
protected function assertPreloaded( $expected, $text, $msg = '' ) {
|
|
$this->assertEquals(
|
|
$expected,
|
|
$this->testParser->getPreloadText(
|
|
$text,
|
|
$this->title,
|
|
$this->testParserOptions
|
|
),
|
|
$msg
|
|
);
|
|
}
|
|
}
|