X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fparser%2FParserMethodsTest.php;h=ae58d1ce06c2634561bd9d784da137dc5fefb7bf;hb=13bb844fdfff794525e2cb202176ddee3a23ef06;hp=af143caa8da683ad6b1dfa0d811cd64d7f87eac1;hpb=9e18610457ce599db51d3b14af83c31053ea0ace;p=lhc%2Fweb%2Fwiklou.git
diff --git a/tests/phpunit/includes/parser/ParserMethodsTest.php b/tests/phpunit/includes/parser/ParserMethodsTest.php
index af143caa8d..ae58d1ce06 100644
--- a/tests/phpunit/includes/parser/ParserMethodsTest.php
+++ b/tests/phpunit/includes/parser/ParserMethodsTest.php
@@ -2,24 +2,23 @@
/**
* @group Database
+ * @covers Parser
*/
-
class ParserMethodsTest extends MediaWikiLangTestCase {
public static function providePreSaveTransform() {
- return array(
- array( 'hello this is ~~~',
+ return [
+ [ 'hello this is ~~~',
"hello this is [[Special:Contributions/127.0.0.1|127.0.0.1]]",
- ),
- array( 'hello \'\'this\'\' is ~~~',
+ ],
+ [ 'hello \'\'this\'\' is ~~~',
'hello \'\'this\'\' is ~~~',
- ),
- );
+ ],
+ ];
}
/**
* @dataProvider providePreSaveTransform
- * @covers Parser::preSaveTransform
*/
public function testPreSaveTransform( $text, $expected ) {
global $wgParser;
@@ -37,33 +36,32 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
// This mimics the most common use case (stripping paragraphs generated by the parser).
$message = new RawMessage( "Message text." );
- return array(
- array(
+ return [
+ [
"
Text.
",
"Text.",
- ),
- array(
+ ],
+ [
"Text.
",
"Text.
",
- ),
- array(
+ ],
+ [
"Text.\n
\n",
"Text.",
- ),
- array(
+ ],
+ [
"Text.
More text.
",
"Text.
More text.
",
- ),
- array(
+ ],
+ [
$message->parse(),
"Message text.",
- ),
- );
+ ],
+ ];
}
/**
* @dataProvider provideStripOuterParagraph
- * @covers Parser::stripOuterParagraph
*/
public function testStripOuterParagraph( $text, $expected ) {
$this->assertEquals( $expected, Parser::stripOuterParagraph( $text ) );
@@ -71,14 +69,14 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
/**
* @expectedException MWException
- * @expectedExceptionMessage Parser state cleared while parsing. Did you call Parser::parse recursively?
- * @covers Parser::lock
+ * @expectedExceptionMessage Parser state cleared while parsing.
+ * Did you call Parser::parse recursively?
*/
public function testRecursiveParse() {
global $wgParser;
$title = Title::newFromText( 'foo' );
$po = new ParserOptions;
- $wgParser->setHook( 'recursivecallparser', array( $this, 'helperParserFunc' ) );
+ $wgParser->setHook( 'recursivecallparser', [ $this, 'helperParserFunc' ] );
$wgParser->parse( 'baz', $title, $po );
}
@@ -89,9 +87,6 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
return 'bar';
}
- /**
- * @covers Parser::callParserFunction
- */
public function testCallParserFunction() {
global $wgParser;
@@ -100,17 +95,17 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
$wgParser->startExternalParse( $title, new ParserOptions(), Parser::OT_HTML );
$frame = $wgParser->getPreprocessor()->newFrame();
$ret = $wgParser->callParserFunction( $frame, '#tag',
- array( 'pre', 'foo', 'style' => 'margin-left: 1.6em' )
+ [ 'pre', 'foo', 'style' => 'margin-left: 1.6em' ]
);
$ret['text'] = $wgParser->mStripState->unstripBoth( $ret['text'] );
- $this->assertSame( array(
+ $this->assertSame( [
'found' => true,
'text' => 'foo
',
- ), $ret, 'callParserFunction works for {{#tag:pre|foo|style=margin-left: 1.6em}}' );
+ ], $ret, 'callParserFunction works for {{#tag:pre|foo|style=margin-left: 1.6em}}' );
}
/**
- * @covers Parser::parse
+ * @covers Parser
* @covers ParserOutput::getSections
*/
public function testGetSections() {
@@ -118,8 +113,8 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
$title = Title::newFromText( str_replace( '::', '__', __METHOD__ ) );
$out = $wgParser->parse( "==foo==\nbar
\n==baz==\n", $title, new ParserOptions() );
- $this->assertSame( array(
- array(
+ $this->assertSame( [
+ [
'toclevel' => 1,
'level' => '2',
'line' => 'foo',
@@ -128,8 +123,8 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
'fromtitle' => $title->getPrefixedDBkey(),
'byteoffset' => 0,
'anchor' => 'foo',
- ),
- array(
+ ],
+ [
'toclevel' => 1,
'level' => '2',
'line' => 'bar',
@@ -138,8 +133,8 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
'fromtitle' => false,
'byteoffset' => null,
'anchor' => 'bar',
- ),
- array(
+ ],
+ [
'toclevel' => 1,
'level' => '2',
'line' => 'baz',
@@ -148,42 +143,40 @@ class ParserMethodsTest extends MediaWikiLangTestCase {
'fromtitle' => $title->getPrefixedDBkey(),
'byteoffset' => 21,
'anchor' => 'baz',
- ),
- ), $out->getSections(), 'getSections() with proper value when is used' );
+ ],
+ ], $out->getSections(), 'getSections() with proper value when is used' );
}
/**
* @dataProvider provideNormalizeLinkUrl
- * @covers Parser::normalizeLinkUrl
- * @covers Parser::normalizeUrlComponent
*/
public function testNormalizeLinkUrl( $explanation, $url, $expected ) {
$this->assertEquals( $expected, Parser::normalizeLinkUrl( $url ), $explanation );
}
public static function provideNormalizeLinkUrl() {
- return array(
- array(
+ return [
+ [
'Escaping of unsafe characters',
'http://example.org/foo bar?param[]="value"¶m[]=valüe',
'http://example.org/foo%20bar?param%5B%5D=%22value%22¶m%5B%5D=val%C3%BCe',
- ),
- array(
+ ],
+ [
'Case normalization of percent-encoded characters',
'http://example.org/%ab%cD%Ef%FF',
'http://example.org/%AB%CD%EF%FF',
- ),
- array(
+ ],
+ [
'Unescaping of safe characters',
'http://example.org/%3C%66%6f%6F%3E?%3C%66%6f%6F%3E#%3C%66%6f%6F%3E',
'http://example.org/%3Cfoo%3E?%3Cfoo%3E#%3Cfoo%3E',
- ),
- array(
+ ],
+ [
'Context-sensitive replacement of sometimes-safe characters',
'http://example.org/%23%2F%3F%26%3D%2B%3B?%23%2F%3F%26%3D%2B%3B#%23%2F%3F%26%3D%2B%3B',
'http://example.org/%23%2F%3F&=+;?%23/?%26%3D%2B%3B#%23/?&=+;',
- ),
- );
+ ],
+ ];
}
// @todo Add tests for cleanSig() / cleanSigInSig(), getSection(),