X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fparser%2FTagHooksTest.php;h=7e31cba60fc671b21fcb0419b2d988da905c05bb;hp=12936ee21d10248063e33ea5804655c5d490c751;hb=08edb27f6ce31c676660a4ef89b87da79bde2cc2;hpb=32f52cbacd760f8c1cb60345fe0310cbc8d7a4ec diff --git a/tests/phpunit/includes/parser/TagHooksTest.php b/tests/phpunit/includes/parser/TagHooksTest.php index 12936ee21d..7e31cba60f 100644 --- a/tests/phpunit/includes/parser/TagHooksTest.php +++ b/tests/phpunit/includes/parser/TagHooksTest.php @@ -28,7 +28,7 @@ * @covers PPNode_Hash_Array * @covers PPNode_Hash_Attr */ -class TagHookTest extends MediaWikiTestCase { +class TagHooksTest extends MediaWikiTestCase { public static function provideValidNames() { return [ [ 'foo' ], @@ -43,18 +43,25 @@ class TagHookTest extends MediaWikiTestCase { return [ [ "foobar" ], [ "foo\nbar" ], [ "foo\rbar" ] ]; } + private function getParserOptions() { + global $wgContLang; + $popt = ParserOptions::newFromUserAndLang( new User, $wgContLang ); + $popt->setWrapOutputClass( false ); + return $popt; + } + /** * @dataProvider provideValidNames */ public function testTagHooks( $tag ) { - global $wgParserConf, $wgContLang; + global $wgParserConf; $parser = new Parser( $wgParserConf ); $parser->setHook( $tag, [ $this, 'tagCallback' ] ); $parserOutput = $parser->parse( "Foo<$tag>BarBaz", Title::newFromText( 'Test' ), - ParserOptions::newFromUserAndLang( new User, $wgContLang ) + $this->getParserOptions() ); $this->assertEquals( "

FooOneBaz\n

", $parserOutput->getText() ); @@ -66,14 +73,14 @@ class TagHookTest extends MediaWikiTestCase { * @expectedException MWException */ public function testBadTagHooks( $tag ) { - global $wgParserConf, $wgContLang; + global $wgParserConf; $parser = new Parser( $wgParserConf ); $parser->setHook( $tag, [ $this, 'tagCallback' ] ); $parser->parse( "Foo<$tag>BarBaz", Title::newFromText( 'Test' ), - ParserOptions::newFromUserAndLang( new User, $wgContLang ) + $this->getParserOptions() ); $this->fail( 'Exception not thrown.' ); } @@ -82,14 +89,14 @@ class TagHookTest extends MediaWikiTestCase { * @dataProvider provideValidNames */ public function testFunctionTagHooks( $tag ) { - global $wgParserConf, $wgContLang; + global $wgParserConf; $parser = new Parser( $wgParserConf ); $parser->setFunctionTagHook( $tag, [ $this, 'functionTagCallback' ], 0 ); $parserOutput = $parser->parse( "Foo<$tag>BarBaz", Title::newFromText( 'Test' ), - ParserOptions::newFromUserAndLang( new User, $wgContLang ) + $this->getParserOptions() ); $this->assertEquals( "

FooOneBaz\n

", $parserOutput->getText() ); @@ -101,7 +108,7 @@ class TagHookTest extends MediaWikiTestCase { * @expectedException MWException */ public function testBadFunctionTagHooks( $tag ) { - global $wgParserConf, $wgContLang; + global $wgParserConf; $parser = new Parser( $wgParserConf ); $parser->setFunctionTagHook( @@ -112,7 +119,7 @@ class TagHookTest extends MediaWikiTestCase { $parser->parse( "Foo<$tag>BarBaz", Title::newFromText( 'Test' ), - ParserOptions::newFromUserAndLang( new User, $wgContLang ) + $this->getParserOptions() ); $this->fail( 'Exception not thrown.' ); }