From e8619ba7497703cdb39c13504e7e4588e594854f Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Wed, 25 Oct 2017 02:07:59 +0100 Subject: [PATCH] API: Add tests for useskin parameter of ApiParse Change-Id: If3dff7be5ccb6791f95d37c06998fcbadf1f469f --- tests/phpunit/includes/api/ApiParseTest.php | 38 +++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/phpunit/includes/api/ApiParseTest.php b/tests/phpunit/includes/api/ApiParseTest.php index 028d3b4135..7d33fbc5cd 100644 --- a/tests/phpunit/includes/api/ApiParseTest.php +++ b/tests/phpunit/includes/api/ApiParseTest.php @@ -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' + ); + } } -- 2.20.1