Merge "StringUtils: Add a utility for checking if a string is a valid regex"
[lhc/web/wiklou.git] / tests / phpunit / includes / ExtraParserTest.php
index 7ce4d1e..fc317b7 100644 (file)
@@ -46,6 +46,25 @@ class ExtraParserTest extends MediaWikiTestCase {
                        $this->parser->parse( $longLine, $title, $options )->getText( [ 'unwrap' => true ] ) );
        }
 
+       /**
+        * @covers Parser::braceSubstitution
+        * @covers SpecialPageFactory::capturePath
+        */
+       public function testSpecialPageTransclusionRestoresGlobalState() {
+               $text = "{{Special:ApiHelp/help}}";
+               $title = Title::newFromText( 'testSpecialPageTransclusionRestoresGlobalState' );
+               $options = ParserOptions::newFromUser( new User() );
+
+               RequestContext::getMain()->setTitle( $title );
+               RequestContext::getMain()->getWikiPage()->CustomTestProp = true;
+
+               $parsed = $this->parser->parse( $text, $title, $options )->getText();
+               $this->assertContains( 'apihelp-header', $parsed );
+
+               // Verify that this property wasn't wiped out by the parse
+               $this->assertTrue( RequestContext::getMain()->getWikiPage()->CustomTestProp );
+       }
+
        /**
         * Test the parser entry points
         * @covers Parser::parse