API: Add tests for useskin parameter of ApiParse
[lhc/web/wiklou.git] / 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'
+               );
+       }
 }