*/
class ExtraParserTest extends MediaWikiTestCase {
- function setUp() {
- global $wgMemc;
- global $wgContLang;
- global $wgShowDBErrorBacktrace;
- global $wgLanguageCode;
- global $wgAlwaysUseTidy;
+ protected function setUp() {
+ parent::setUp();
- $wgShowDBErrorBacktrace = true;
- $wgLanguageCode = 'en';
- $wgContLang = new Language( 'en' );
- $wgMemc = new EmptyBagOStuff;
- $wgAlwaysUseTidy = false;
+ $contLang = Language::factory( 'en' );
+ $this->setMwGlobals( array(
+ 'wgShowDBErrorBacktrace' => true,
+ 'wgLanguageCode' => 'en',
+ 'wgContLang' => $contLang,
+ 'wgLang' => Language::factory( 'en' ),
+ 'wgMemc' => new EmptyBagOStuff,
+ 'wgAlwaysUseTidy' => false,
+ 'wgCleanSignatures' => true,
+ ) );
- $this->options = new ParserOptions;
+ $this->options = ParserOptions::newFromUserAndLang( new User, $contLang );
$this->options->setTemplateCallback( array( __CLASS__, 'statelessFetchTemplate' ) );
$this->parser = new Parser;
// Bug 8689 - Long numeric lines kill the parser
function testBug8689() {
- global $wgLang;
global $wgUser;
$longLine = '1.' . str_repeat( '1234567890', 100000 ) . "\n";
-
- if ( $wgLang === null ) $wgLang = new Language;
$t = Title::newFromText( 'Unit test' );
$options = ParserOptions::newFromUser( $wgUser );
* cleanSig() makes all templates substs and removes tildes
*/
function testCleanSig() {
- global $wgCleanSignatures;
- $oldCleanSignature = $wgCleanSignatures;
- $wgCleanSignatures = true;
-
$title = Title::newFromText( __FUNCTION__ );
$outputText = $this->parser->cleanSig( "{{Foo}} ~~~~" );
-
- $wgCleanSignatures = $oldCleanSignature;
$this->assertEquals( "{{SUBST:Foo}} ", $outputText );
}
*/
function testCleanSigDisabled() {
global $wgCleanSignatures;
- $oldCleanSignature = $wgCleanSignatures;
$wgCleanSignatures = false;
$title = Title::newFromText( __FUNCTION__ );
$outputText = $this->parser->cleanSig( "{{Foo}} ~~~~" );
-
- $wgCleanSignatures = $oldCleanSignature;
$this->assertEquals( "{{Foo}} ~~~~", $outputText );
}
$this->assertEquals( Parser::cleanSigInSig( $in), $out );
}
- function provideStringsForCleanSigInSig() {
+ public static function provideStringsForCleanSigInSig() {
return array(
array( "{{Foo}} ~~~~", "{{Foo}} " ),
array( "~~~", "" ),