Merge "EditPage: switch from NS_CATEGORY check to instanceof CategoryPage"
[lhc/web/wiklou.git] / tests / phpunit / includes / skins / SkinTemplateTest.php
index 8084a66..b843d17 100644 (file)
@@ -23,20 +23,78 @@ class SkinTemplateTest extends MediaWikiTestCase {
        }
 
        public function makeListItemProvider() {
-               return array(
-                       array(
+               return [
+                       [
                                '<li class="class" title="itemtitle"><a href="url" title="title">text</a></li>',
                                '',
-                               array(
+                               [
                                        'class' => 'class',
                                        'itemtitle' => 'itemtitle',
                                        'href' => 'url',
                                        'title' => 'title',
                                        'text' => 'text'
-                               ),
-                               array(),
-                               'Test makteListItem with normal values'
-                       )
-               );
+                               ],
+                               [],
+                               'Test makeListItem with normal values'
+                       ]
+               ];
+       }
+
+       /**
+        * @return PHPUnit_Framework_MockObject_MockObject|OutputPage
+        */
+       private function getMockOutputPage( $isSyndicated, $html ) {
+               $mock = $this->getMock( OutputPage::class );
+               $mock->expects( $this->once() )
+                       ->method( 'isSyndicated' )
+                       ->will( $this->returnValue( $isSyndicated ) );
+               $mock->expects( $this->once() )
+                       ->method( 'getHTML' )
+                       ->will( $this->returnValue( $html ) );
+               return $mock;
+       }
+
+       public function provideSetupSkinUserCss() {
+               $defaultStyles = [
+                       'mediawiki.legacy.shared',
+                       'mediawiki.legacy.commonPrint',
+                       'mediawiki.sectionAnchor',
+               ];
+               $buttonStyle = 'mediawiki.ui.button';
+               $feedStyle = 'mediawiki.feedlink';
+               return [
+                       [
+                               $this->getMockOutputPage( false, '' ),
+                               $defaultStyles
+                       ],
+                       [
+                               $this->getMockOutputPage( true, '' ),
+                               array_merge( $defaultStyles, [ $feedStyle ] )
+                       ],
+                       [
+                               $this->getMockOutputPage( false, 'FOO mw-ui-button BAR' ),
+                               array_merge( $defaultStyles, [ $buttonStyle ] )
+                       ],
+                       [
+                               $this->getMockOutputPage( true, 'FOO mw-ui-button BAR' ),
+                               array_merge( $defaultStyles, [ $feedStyle, $buttonStyle ] )
+                       ],
+               ];
+       }
+
+       /**
+        * @param PHPUnit_Framework_MockObject_MockObject|OutputPage $outputPageMock
+        * @param string[] $expectedModuleStyles
+        *
+        * @covers SkinTemplate::setupSkinUserCss
+        * @dataProvider provideSetupSkinUserCss
+        */
+       public function testSetupSkinUserCss( $outputPageMock, $expectedModuleStyles ) {
+               $outputPageMock->expects( $this->once() )
+                       ->method( 'addModuleStyles' )
+                       ->with( $expectedModuleStyles );
+
+               $skinTemplate = new SkinTemplate();
+               $skinTemplate->setupSkinUserCss( $outputPageMock );
        }
 }