X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FLinkerTest.php;h=e50b4f14901c21e51afa7bcd3711d09e3ceec848;hb=6fa889309d6dde3bcfd1c5f939e317abf0f3e790;hp=b8b5a77379d87e66501f1c2d9172c6b7140675a6;hpb=bfdd3369c26b10307c7e6f428aa03e2b38b9ec1d;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/LinkerTest.php b/tests/phpunit/includes/LinkerTest.php index b8b5a77379..e50b4f1490 100644 --- a/tests/phpunit/includes/LinkerTest.php +++ b/tests/phpunit/includes/LinkerTest.php @@ -11,10 +11,10 @@ class LinkerTest extends MediaWikiLangTestCase { * @covers Linker::userLink */ public function testUserLink( $expected, $userId, $userName, $altUserName = false, $msg = '' ) { - $this->setMwGlobals( array( + $this->setMwGlobals( [ 'wgArticlePath' => '/wiki/$1', 'wgWellFormedXml' => true, - ) ); + ] ); $this->assertEquals( $expected, Linker::userLink( $userId, $userName, $altUserName, $msg ) @@ -28,63 +28,63 @@ class LinkerTest extends MediaWikiLangTestCase { # - username # - optional altUserName # - optional message - return array( + return [ # ## ANONYMOUS USER ######################################## - array( + [ 'JohnDoe', 0, 'JohnDoe', false, - ), - array( + ], + [ '::1', 0, '::1', false, 'Anonymous with pretty IPv6' - ), - array( + ], + [ '::1', 0, '0:0:0:0:0:0:0:1', false, 'Anonymous with almost pretty IPv6' - ), - array( + ], + [ '::1', 0, '0000:0000:0000:0000:0000:0000:0000:0001', false, 'Anonymous with full IPv6' - ), - array( + ], + [ 'AlternativeUsername', 0, '::1', 'AlternativeUsername', 'Anonymous with pretty IPv6 and an alternative username' - ), + ], # IPV4 - array( + [ '127.0.0.1', 0, '127.0.0.1', false, 'Anonymous with IPv4' - ), - array( + ], + [ 'AlternativeUsername', 0, '127.0.0.1', 'AlternativeUsername', 'Anonymous with IPv4 and an alternative username' - ), + ], # ## Regular user ########################################## # TODO! - ); + ]; } /** @@ -97,25 +97,25 @@ class LinkerTest extends MediaWikiLangTestCase { $expected, $comment, $title = false, $local = false, $wikiId = null ) { $conf = new SiteConfiguration(); - $conf->settings = array( - 'wgServer' => array( + $conf->settings = [ + 'wgServer' => [ 'enwiki' => '//en.example.org', 'dewiki' => '//de.example.org', - ), - 'wgArticlePath' => array( + ], + 'wgArticlePath' => [ 'enwiki' => '/w/$1', 'dewiki' => '/w/$1', - ), - ); - $conf->suffixes = array( 'wiki' ); + ], + ]; + $conf->suffixes = [ 'wiki' ]; - $this->setMwGlobals( array( + $this->setMwGlobals( [ 'wgScript' => '/wiki/index.php', 'wgArticlePath' => '/wiki/$1', 'wgWellFormedXml' => true, 'wgCapitalLinks' => true, 'wgConf' => $conf, - ) ); + ] ); if ( $title === false ) { // We need a page title that exists @@ -132,129 +132,129 @@ class LinkerTest extends MediaWikiLangTestCase { $wikiId = 'enwiki'; // $wgConf has a fake entry for this // @codingStandardsIgnoreStart Generic.Files.LineLength - return array( + return [ // Linker::formatComment - array( + [ 'a<script>b', 'a */" - ), - array( + ], + [ '→‎autocomment', "/* autocomment */", false, true - ), - array( + ], + [ '‎autocomment', "/* autocomment */", null - ), - array( + ], + [ '→‎autocomment', "/* autocomment */", false, false - ), - array( + ], + [ '→‎autocomment', "/* autocomment */", false, false, $wikiId - ), + ], // Linker::formatLinksInComment - array( + [ 'abc link def', "abc [[link]] def", - ), - array( + ], + [ 'abc text def', "abc [[link|text]] def", - ), - array( + ], + [ 'abc Special:BlankPage def', "abc [[Special:BlankPage|]] def", - ), - array( + ], + [ 'abc ąśż def', "abc [[%C4%85%C5%9B%C5%BC]] def", - ), - array( + ], + [ 'abc #section def', "abc [[#section]] def", - ), - array( + ], + [ 'abc /subpage def', "abc [[/subpage]] def", - ), - array( + ], + [ 'abc "evil!" def', "abc [[\"evil!\"]] def", - ), - array( + ], + [ 'abc [[<script>very evil</script>]] def', "abc [[]] def", - ), - array( + ], + [ 'abc [[|]] def', "abc [[|]] def", - ), - array( + ], + [ 'abc link def', "abc [[link]] def", false, false - ), - array( + ], + [ 'abc link def', "abc [[link]] def", false, false, $wikiId - ) - ); + ], + ]; // @codingStandardsIgnoreEnd } @@ -265,22 +265,22 @@ class LinkerTest extends MediaWikiLangTestCase { public function testFormatLinksInComment( $expected, $input, $wiki ) { $conf = new SiteConfiguration(); - $conf->settings = array( - 'wgServer' => array( + $conf->settings = [ + 'wgServer' => [ 'enwiki' => '//en.example.org' - ), - 'wgArticlePath' => array( + ], + 'wgArticlePath' => [ 'enwiki' => '/w/$1', - ), - ); - $conf->suffixes = array( 'wiki' ); - $this->setMwGlobals( array( + ], + ]; + $conf->suffixes = [ 'wiki' ]; + $this->setMwGlobals( [ 'wgScript' => '/wiki/index.php', 'wgArticlePath' => '/wiki/$1', 'wgWellFormedXml' => true, 'wgCapitalLinks' => true, 'wgConf' => $conf, - ) ); + ] ); $this->assertEquals( $expected, @@ -289,22 +289,24 @@ class LinkerTest extends MediaWikiLangTestCase { } public static function provideCasesForFormatLinksInComment() { - return array( - array( + // @codingStandardsIgnoreStart Generic.Files.LineLength + return [ + [ 'foo bar Special:BlankPage', 'foo bar [[Special:BlankPage]]', null, - ), - array( + ], + [ 'Foo\'bar', "[[Foo'bar]]", 'enwiki', - ), - array( + ], + [ 'foo bar Special:BlankPage', 'foo bar [[Special:BlankPage]]', 'enwiki', - ), - ); + ], + ]; + // @codingStandardsIgnoreEnd } }