X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FLinkerTest.php;h=e50b4f14901c21e51afa7bcd3711d09e3ceec848;hb=6fa889309d6dde3bcfd1c5f939e317abf0f3e790;hp=19ab56f80b9e7a6034384f691eb466dae4465e51;hpb=8d1c5a70f753fe6b7d2533a30b07fe03e6583a1d;p=lhc%2Fweb%2Fwiklou.git
diff --git a/tests/phpunit/includes/LinkerTest.php b/tests/phpunit/includes/LinkerTest.php
index 19ab56f80b..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
@@ -131,129 +131,131 @@ class LinkerTest extends MediaWikiLangTestCase {
public function provideCasesForFormatComment() {
$wikiId = 'enwiki'; // $wgConf has a fake entry for this
- return array(
+ // @codingStandardsIgnoreStart Generic.Files.LineLength
+ return [
// Linker::formatComment
- array(
+ [
'a<script>b',
'a */"
- ),
- array(
+ ],
+ [
'ââ',
"/* autocomment */",
false, true
- ),
- array(
+ ],
+ [
'â',
"/* autocomment */",
null
- ),
- array(
+ ],
+ [
'ââ',
"/* autocomment */",
false, false
- ),
- array(
+ ],
+ [
'ââ',
"/* 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
}
/**
@@ -263,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,
@@ -287,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
}
}