X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fapi%2FApiParseTest.php;h=e236437722f7cd66313c7140d4b0d2d6f006b16d;hb=bdf062a8e9f351d3b94f99f2cbe9f7176f0b8801;hp=028d3b413536f7c4f7ce636ae2e570782c6fdaed;hpb=bc28fc4c4844a536288a26b514a12d6ed8d6860c;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/api/ApiParseTest.php b/tests/phpunit/includes/api/ApiParseTest.php index 028d3b4135..e236437722 100644 --- a/tests/phpunit/includes/api/ApiParseTest.php +++ b/tests/phpunit/includes/api/ApiParseTest.php @@ -21,7 +21,7 @@ class ApiParseTest extends ApiTestCase { ContentHandler::makeContent( 'Test for revdel', $title, CONTENT_MODEL_WIKITEXT ), __METHOD__ . ' Test for revdel', 0, false, $user ); - if ( !$status->isOk() ) { + if ( !$status->isOK() ) { $this->fail( "Failed to create $title: " . $status->getWikiText( false, false, 'en' ) ); } self::$pageId = $status->value['revision']->getPage(); @@ -31,7 +31,7 @@ class ApiParseTest extends ApiTestCase { ContentHandler::makeContent( 'Test for oldid', $title, CONTENT_MODEL_WIKITEXT ), __METHOD__ . ' Test for oldid', 0, false, $user ); - if ( !$status->isOk() ) { + if ( !$status->isOK() ) { $this->fail( "Failed to edit $title: " . $status->getWikiText( false, false, 'en' ) ); } self::$revIds['oldid'] = $status->value['revision']->getId(); @@ -40,7 +40,7 @@ class ApiParseTest extends ApiTestCase { ContentHandler::makeContent( 'Test for latest', $title, CONTENT_MODEL_WIKITEXT ), __METHOD__ . ' Test for latest', 0, false, $user ); - if ( !$status->isOk() ) { + if ( !$status->isOK() ) { $this->fail( "Failed to edit $title: " . $status->getWikiText( false, false, 'en' ) ); } self::$revIds['latest'] = $status->value['revision']->getId(); @@ -129,4 +129,46 @@ class ApiParseTest extends ApiTestCase { ); } } + + public function testSkinModules() { + $factory = new SkinFactory(); + $factory->register( 'testing', 'Testing', function () { + $skin = $this->getMockBuilder( SkinFallback::class ) + ->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 ); + + $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( + [ 'foo.styles' ], + $res[0]['parse']['modulestyles'], + 'resp.parse.modulestyles' + ); + } }