API: Add tests for useskin parameter of ApiParse
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 25 Oct 2017 01:07:59 +0000 (02:07 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Wed, 25 Oct 2017 01:07:59 +0000 (02:07 +0100)
Change-Id: If3dff7be5ccb6791f95d37c06998fcbadf1f469f

tests/phpunit/includes/api/ApiParseTest.php

index 028d3b4..7d33fbc 100644 (file)
@@ -129,4 +129,42 @@ class ApiParseTest extends ApiTestCase {
                        );
                }
        }
+
+       public function testSkinModules() {
+               $factory = new SkinFactory();
+               $factory->register( 'testing', 'Testing', function () {
+                       $skin = $this->getMockBuilder( SkinFallback::class )
+                               ->setMethods( [ 'getDefaultModules' ] )
+                               ->getMock();
+                       $skin->expects( $this->once() )->method( 'getDefaultModules' )
+                               ->willReturn( [
+                                       'core' => [ 'foo', 'bar' ],
+                                       'content' => [ 'baz' ]
+                               ] );
+                       return $skin;
+               } );
+               $this->setService( 'SkinFactory', $factory );
+
+               $res = $this->doApiRequest( [
+                       'action' => 'parse',
+                       'pageid' => self::$pageId,
+                       'useskin' => 'testing',
+                       'prop' => 'modules',
+               ] );
+               $this->assertSame(
+                       [ 'foo', 'bar', 'baz' ],
+                       $res[0]['parse']['modules'],
+                       'resp.parse.modules'
+               );
+               $this->assertSame(
+                       [],
+                       $res[0]['parse']['modulescripts'],
+                       'resp.parse.modulescripts'
+               );
+               $this->assertSame(
+                       [],
+                       $res[0]['parse']['modulestyles'],
+                       'resp.parse.modulestyles'
+               );
+       }
 }