18 $contLang = Language::factory(
'en' );
20 'wgShowDBErrorBacktrace' =>
true,
21 'wgCleanSignatures' =>
true,
27 $this->
options = ParserOptions::newFromUserAndLang(
new User, $contLang );
28 $this->
options->setTemplateCallback( [ __CLASS__,
'statelessFetchTemplate' ] );
29 $this->parser =
new Parser;
39 $longLine =
'1.' . str_repeat(
'1234567890', 100000 ) .
"\n";
41 $title = Title::newFromText(
'Unit test' );
43 $this->assertEquals(
"<p>$longLine</p>",
44 $this->parser->parse( $longLine, $title,
$options )->getText( [
'unwrap' =>
true ] ) );
52 $title = Title::newFromText( __FUNCTION__ );
53 $parserOutput = $this->parser->parse(
"Test\n{{Foo}}\n{{Bar}}", $title, $this->
options );
55 "<p>Test\nContent of <i>Template:Foo</i>\nContent of <i>Template:Bar</i>\n</p>",
56 $parserOutput->getText( [
'unwrap' =>
true ] )
64 $title = Title::newFromText( __FUNCTION__ );
65 $outputText = $this->parser->preSaveTransform(
66 "Test\r\n{{subst:Foo}}\n{{Bar}}",
72 $this->assertEquals(
"Test\nContent of ''Template:Foo''\n{{Bar}}", $outputText );
79 $title = Title::newFromText( __FUNCTION__ );
80 $outputText = $this->parser->preprocess(
"Test\n{{Foo}}\n{{Bar}}", $title, $this->
options );
83 "Test\nContent of ''Template:Foo''\nContent of ''Template:Bar''",
93 $title = Title::newFromText( __FUNCTION__ );
94 $outputText = $this->parser->cleanSig(
"{{Foo}} ~~~~" );
96 $this->assertEquals(
"{{SUBST:Foo}} ", $outputText );
106 $title = Title::newFromText( __FUNCTION__ );
107 $outputText = $this->parser->cleanSig(
"{{Foo}} ~~~~" );
109 $this->assertEquals(
"{{Foo}} ~~~~", $outputText );
118 $this->assertEquals( Parser::cleanSigInSig( $in ),
$out );
123 [
"{{Foo}} ~~~~",
"{{Foo}} " ],
133 $outputText2 = $this->parser->getSection(
134 "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\n"
135 .
"Section 2\n== Heading 3 ==\nSection 3\n",
138 $outputText1 = $this->parser->getSection(
139 "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\n"
140 .
"Section 2\n== Heading 3 ==\nSection 3\n",
144 $this->assertEquals(
"=== Heading 2 ===\nSection 2", $outputText2 );
145 $this->assertEquals(
"== Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2", $outputText1 );
152 $outputText = $this->parser->replaceSection(
153 "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\n"
154 .
"Section 2\n== Heading 3 ==\nSection 3\n",
159 $this->assertEquals(
"Section 0\nNew section 1\n\n== Heading 3 ==\nSection 3", $outputText );
167 $title = Title::newFromText( __FUNCTION__ );
168 $outputText = $this->parser->getPreloadText(
169 "{{Foo}}<noinclude> censored</noinclude> information <!-- is very secret -->",
174 $this->assertEquals(
"{{Foo}} information <!-- is very secret -->", $outputText );
184 $text =
"Content of ''" . $title->getFullText() .
"''";
197 $title = Title::newFromText( __FUNCTION__ );
198 $catName =
wfMessage(
'broken-file-category' )->inContentLanguage()->text();
199 $cat = Title::makeTitleSafe(
NS_CATEGORY, $catName );
200 $expected = [ $cat->getDBkey() ];
201 $parserOutput = $this->parser->parse(
"[[file:nonexistent]]", $title, $this->
options );
202 $result = $parserOutput->getCategoryLinks();
203 $this->assertEquals( $expected, $result );
211 $title = SpecialPage::getTitleFor(
'Contributions' );
212 $parserOutput = $this->parser->parse(
"[[file:nonexistent]]", $title, $this->
options );
213 $result = $parserOutput->getCategoryLinks();
214 $this->assertEmpty( $result );
static clearCache()
Clear the self::$mObjects variable For use in parser tests.
Set options of the Parser.
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing options(say) and put it in one place. Instead of having little title-reversing if-blocks spread all over the codebase in showAnArticle
namespace and then decline to actually register it file or subcat img or subcat $title
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out