Merge "API: Include setupSkinUserCss in prop=modules for useskin mode"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 25 Oct 2017 15:24:03 +0000 (15:24 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 25 Oct 2017 15:24:04 +0000 (15:24 +0000)
includes/api/ApiParse.php
tests/phpunit/includes/api/ApiParseTest.php

index 7cbd353..15b94fb 100644 (file)
@@ -329,6 +329,8 @@ class ApiParse extends ApiBase {
                        $context->setOutput( $outputPage );
 
                        if ( $skin ) {
+                               // Based on OutputPage::headElement()
+                               $skin->setupSkinUserCss( $outputPage );
                                // Based on OutputPage::output()
                                foreach ( $skin->getDefaultModules() as $group ) {
                                        $outputPage->addModules( $group );
index 7d33fbc..07bf299 100644 (file)
@@ -134,13 +134,17 @@ class ApiParseTest extends ApiTestCase {
                $factory = new SkinFactory();
                $factory->register( 'testing', 'Testing', function () {
                        $skin = $this->getMockBuilder( SkinFallback::class )
-                               ->setMethods( [ 'getDefaultModules' ] )
+                               ->setMethods( [ 'getDefaultModules', 'setupSkinUserCss' ] )
                                ->getMock();
                        $skin->expects( $this->once() )->method( 'getDefaultModules' )
                                ->willReturn( [
                                        'core' => [ 'foo', 'bar' ],
                                        'content' => [ 'baz' ]
                                ] );
+                       $skin->expects( $this->once() )->method( 'setupSkinUserCss' )
+                               ->will( $this->returnCallback( function ( OutputPage $out ) {
+                                       $out->addModuleStyles( 'foo.styles' );
+                               } ) );
                        return $skin;
                } );
                $this->setService( 'SkinFactory', $factory );
@@ -162,7 +166,7 @@ class ApiParseTest extends ApiTestCase {
                        'resp.parse.modulescripts'
                );
                $this->assertSame(
-                       [],
+                       [ 'foo.styles' ],
                        $res[0]['parse']['modulestyles'],
                        'resp.parse.modulestyles'
                );