X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FOutputPageTest.php;h=52103f97cc293c6a32b047a70b04493f738fce71;hb=1abc89fc7651e122ca53fe874eecb89f30b5ba35;hp=97df585f8b0ad1f768702940e4acd846f6d302a2;hpb=143f36732f4af09ad1696a5f9a18122047004590;p=lhc%2Fweb%2Fwiklou.git
diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php
index 97df585f8b..52103f97cc 100644
--- a/tests/phpunit/includes/OutputPageTest.php
+++ b/tests/phpunit/includes/OutputPageTest.php
@@ -293,7 +293,7 @@ class OutputPageTest extends MediaWikiTestCase {
[
[ 'test.quux', ResourceLoaderModule::TYPE_SCRIPTS ],
""
],
];
@@ -344,6 +344,88 @@ class OutputPageTest extends MediaWikiTestCase {
$this->assertEquals( $expectedHtml, $actualHtml );
}
+ public static function provideBuildExemptModules() {
+ return [
+ 'empty' => [
+ 'exemptStyleModules' => [],
+ '',
+ ],
+ 'empty sets' => [
+ 'exemptStyleModules' => [ 'site' => [], 'noscript' => [], 'private' => [], 'user' => [] ],
+ '',
+ ],
+ // @codingStandardsIgnoreStart Generic.Files.LineLength
+ 'default logged-out' => [
+ 'exemptStyleModules' => [ 'site' => [ 'site.styles' ] ],
+ '' . "\n" .
+ '',
+ ],
+ 'default logged-in' => [
+ 'exemptStyleModules' => [ 'site' => [ 'site.styles' ], 'user' => [ 'user.styles' ] ],
+ '' . "\n" .
+ '' . "\n" .
+ '',
+ ],
+ 'custom modules' => [
+ 'exemptStyleModules' => [
+ 'site' => [ 'site.styles', 'example.site.a', 'example.site.b' ],
+ 'user' => [ 'user.styles', 'example.user' ],
+ ],
+ '' . "\n" .
+ '' . "\n" .
+ '' . "\n" .
+ '' . "\n" .
+ '',
+ ],
+ // @codingStandardsIgnoreEnd Generic.Files.LineLength
+ ];
+ }
+
+ /**
+ * @dataProvider provideBuildExemptModules
+ * @covers OutputPage::buildExemptModules
+ */
+ public function testBuildExemptModules( array $exemptStyleModules, $expect ) {
+ $this->setMwGlobals( [
+ 'wgResourceLoaderDebug' => false,
+ 'wgLoadScript' => '/w/load.php',
+ // Stub wgCacheEpoch as it influences getVersionHash used for the
+ // urls in the expected HTML
+ 'wgCacheEpoch' => '20140101000000',
+ ] );
+
+ // Set up stubs
+ $ctx = new RequestContext();
+ $ctx->setSkin( SkinFactory::getDefaultInstance()->makeSkin( 'fallback' ) );
+ $ctx->setLanguage( 'en' );
+ $outputPage = $this->getMockBuilder( 'OutputPage' )
+ ->setConstructorArgs( [ $ctx ] )
+ ->setMethods( [ 'isUserCssPreview', 'buildCssLinksArray' ] )
+ ->getMock();
+ $outputPage->expects( $this->any() )
+ ->method( 'isUserCssPreview' )
+ ->willReturn( false );
+ $outputPage->expects( $this->any() )
+ ->method( 'buildCssLinksArray' )
+ ->willReturn( [] );
+ $rl = $outputPage->getResourceLoader();
+ $rl->setMessageBlobStore( new NullMessageBlobStore() );
+
+ // Register custom modules
+ $rl->register( [
+ 'example.site.a' => new ResourceLoaderTestModule( [ 'group' => 'site' ] ),
+ 'example.site.b' => new ResourceLoaderTestModule( [ 'group' => 'site' ] ),
+ 'example.user' => new ResourceLoaderTestModule( [ 'group' => 'user' ] ),
+ ] );
+
+ $outputPage = TestingAccessWrapper::newFromObject( $outputPage );
+ $outputPage->rlExemptStyleModules = $exemptStyleModules;
+ $this->assertEquals(
+ $expect,
+ strval( $outputPage->buildExemptModules() )
+ );
+ }
+
/**
* @dataProvider provideVaryHeaders
* @covers OutputPage::addVaryHeader
@@ -449,11 +531,11 @@ class OutputPageTest extends MediaWikiTestCase {
*/
public function testGetCategories() {
$fakeResultWrapper = new FakeResultWrapper( [
- (object) [
+ (object)[
'pp_value' => 1,
'page_title' => 'Test'
],
- (object) [
+ (object)[
'page_title' => 'Test2'
]
] );