X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fskins%2FSideBarTest.php;h=af03fe6325eb9dc80958e1be9e94e4f32e330842;hb=294db5759d49606cd8b0939922b4ffb6b60b9a74;hp=a3122b94468f4bfbcac7be93a376715ef8da32b3;hpb=c0cdf0e91186728c8e283bbcc977d6831f4b93d1;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/skins/SideBarTest.php b/tests/phpunit/skins/SideBarTest.php index a3122b9446..af03fe6325 100644 --- a/tests/phpunit/skins/SideBarTest.php +++ b/tests/phpunit/skins/SideBarTest.php @@ -17,14 +17,14 @@ class SideBarTest extends MediaWikiLangTestCase { private function initMessagesHref() { # List of default messages for the sidebar. The sidebar doesn't care at # all whether they are full URLs, interwiki links or local titles. - $URL_messages = array( + $URL_messages = [ 'mainpage', 'portal-url', 'currentevents-url', 'recentchanges-url', 'randompage-url', 'helppage', - ); + ]; # We're assuming that isValidURI works as advertised: it's also # tested separately, in tests/phpunit/includes/HttpTest.php. @@ -54,7 +54,7 @@ class SideBarTest extends MediaWikiLangTestCase { * @todo this assert method to should be converted to a test using a dataprovider.. */ private function assertSideBar( $expected, $text, $message = '' ) { - $bar = array(); + $bar = []; $this->skin->addToSidebarPlain( $bar, $text ); $this->assertEquals( $expected, $bar, $message ); } @@ -64,10 +64,10 @@ class SideBarTest extends MediaWikiLangTestCase { */ public function testSidebarWithOnlyTwoTitles() { $this->assertSideBar( - array( - 'Title1' => array(), - 'Title2' => array(), - ), + [ + 'Title1' => [], + 'Title2' => [], + ], '* Title1 * Title2 ' @@ -78,15 +78,15 @@ class SideBarTest extends MediaWikiLangTestCase { * @covers SkinTemplate::addToSidebarPlain */ public function testExpandMessages() { - $this->assertSidebar( - array( 'Title' => array( - array( + $this->assertSideBar( + [ 'Title' => [ + [ 'text' => 'Help', 'href' => $this->messages['helppage']['href'], 'id' => 'n-help', 'active' => null - ) - ) ), + ] + ] ], '* Title ** helppage|help ' @@ -97,24 +97,24 @@ class SideBarTest extends MediaWikiLangTestCase { * @covers SkinTemplate::addToSidebarPlain */ public function testExternalUrlsRequireADescription() { - $this->setMwGlobals( array( + $this->setMwGlobals( [ 'wgNoFollowLinks' => true, - 'wgNoFollowDomainExceptions' => array(), - 'wgNoFollowNsExceptions' => array(), - ) ); - $this->assertSidebar( - array( 'Title' => array( + 'wgNoFollowDomainExceptions' => [], + 'wgNoFollowNsExceptions' => [], + ] ); + $this->assertSideBar( + [ 'Title' => [ # ** http://www.mediawiki.org/| Home - array( + [ 'text' => 'Home', 'href' => 'http://www.mediawiki.org/', 'id' => 'n-Home', 'active' => null, 'rel' => 'nofollow', - ), + ], # ** http://valid.no.desc.org/ # ... skipped since it is missing a pipe with a description - ) ), + ] ], '* Title ** http://www.mediawiki.org/| Home ** http://valid.no.desc.org/ @@ -123,30 +123,30 @@ class SideBarTest extends MediaWikiLangTestCase { } /** - * bug 33321 - Make sure there's a | after transforming. + * T35321 - Make sure there's a | after transforming. * @group Database * @covers SkinTemplate::addToSidebarPlain */ public function testTrickyPipe() { - $this->assertSidebar( - array( 'Title' => array( + $this->assertSideBar( + [ 'Title' => [ # The first 2 are skipped # Doesn't really test the url properly # because it will vary with $wgArticlePath et al. # ** Baz|Fred - array( + [ 'text' => 'Fred', 'href' => Title::newFromText( 'Baz' )->getLocalURL(), 'id' => 'n-Fred', 'active' => null, - ), - array( + ], + [ 'text' => 'title-to-display', 'href' => Title::newFromText( 'page-to-go-to' )->getLocalURL(), 'id' => 'n-title-to-display', 'active' => null, - ), - ) ), + ], + ] ], '* Title ** {{PAGENAME|Foo}} ** Bar @@ -162,8 +162,8 @@ class SideBarTest extends MediaWikiLangTestCase { $text = '* Title ** http://www.mediawiki.org/| Home'; - $bar = array(); - $this->skin->addToSideBarPlain( $bar, $text ); + $bar = []; + $this->skin->addToSidebarPlain( $bar, $text ); return $bar['Title'][0]; } @@ -172,12 +172,12 @@ class SideBarTest extends MediaWikiLangTestCase { * Simple test to verify our helper assertAttribs() is functional */ public function testTestAttributesAssertionHelper() { - $this->setMwGlobals( array( + $this->setMwGlobals( [ 'wgNoFollowLinks' => true, - 'wgNoFollowDomainExceptions' => array(), - 'wgNoFollowNsExceptions' => array(), + 'wgNoFollowDomainExceptions' => [], + 'wgNoFollowNsExceptions' => [], 'wgExternalLinkTarget' => false, - ) ); + ] ); $attribs = $this->getAttribs(); $this->assertArrayHasKey( 'rel', $attribs ); @@ -211,9 +211,9 @@ class SideBarTest extends MediaWikiLangTestCase { } public static function dataRespectExternallinktarget() { - return array( - array( '_blank' ), - array( '_self' ), - ); + return [ + [ '_blank' ], + [ '_self' ], + ]; } }