X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fresourceloader%2FResourceLoaderClientHtmlTest.php;h=dbc757f90bdbe20caf367b41d9f2008b34ce6f12;hp=e763a1946620ec011fc9f152ad6f175e6e50d19e;hb=1de7117197761961736ea43b237599569eee93a2;hpb=5453894d7198f0fae405c65cd241a67336a82fed
diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php
index e763a19466..dbc757f90b 100644
--- a/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php
+++ b/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php
@@ -72,6 +72,10 @@ class ResourceLoaderClientHtmlTest extends PHPUnit\Framework\TestCase {
'shouldEmbed' => true,
'styles' => '.shouldembed{}',
],
+ 'test.styles.deprecated' => [
+ 'type' => ResourceLoaderModule::LOAD_STYLES,
+ 'deprecated' => 'Deprecation message.',
+ ],
'test.scripts' => [],
'test.scripts.user' => [ 'group' => 'user' ],
@@ -125,6 +129,7 @@ class ResourceLoaderClientHtmlTest extends PHPUnit\Framework\TestCase {
'test.styles.private',
'test.styles.pure',
'test.styles.shouldembed',
+ 'test.styles.deprecated',
'test.unregistered.styles',
] );
$client->setModuleScripts( [
@@ -145,6 +150,7 @@ class ResourceLoaderClientHtmlTest extends PHPUnit\Framework\TestCase {
'test.styles.user.empty' => 'ready',
'test.styles.private' => 'ready',
'test.styles.shouldembed' => 'ready',
+ 'test.styles.deprecated' => 'ready',
'test.scripts' => 'loading',
'test.scripts.user' => 'loading',
'test.scripts.user.empty' => 'ready',
@@ -155,6 +161,7 @@ class ResourceLoaderClientHtmlTest extends PHPUnit\Framework\TestCase {
],
'styles' => [
'test.styles.pure',
+ 'test.styles.deprecated',
],
'scripts' => [
'test.scripts',
@@ -169,6 +176,13 @@ class ResourceLoaderClientHtmlTest extends PHPUnit\Framework\TestCase {
'test.user',
],
],
+ 'styleDeprecations' => [
+ Xml::encodeJsCall(
+ 'mw.log.warn',
+ [ 'This page is using the deprecated ResourceLoader module "test.styles.deprecated".
+Deprecation message.' ]
+ )
+ ],
];
$access = TestingAccessWrapper::newFromObject( $client );
@@ -186,7 +200,9 @@ class ResourceLoaderClientHtmlTest extends PHPUnit\Framework\TestCase {
$context = self::makeContext();
$context->getResourceLoader()->register( self::makeSampleModules() );
- $client = new ResourceLoaderClientHtml( $context );
+ $client = new ResourceLoaderClientHtml( $context, [
+ 'nonce' => false,
+ ] );
$client->setConfig( [ 'key' => 'value' ] );
$client->setModules( [
'test',
@@ -195,6 +211,7 @@ class ResourceLoaderClientHtmlTest extends PHPUnit\Framework\TestCase {
$client->setModuleStyles( [
'test.styles.pure',
'test.styles.private',
+ 'test.styles.deprecated',
] );
$client->setModuleScripts( [
'test.scripts',
@@ -207,18 +224,18 @@ class ResourceLoaderClientHtmlTest extends PHPUnit\Framework\TestCase {
$expected = '' . "\n"
. '' . "\n"
- . '' . "\n"
+ . '' . "\n"
. '' . "\n"
. '';
// phpcs:enable
$expected = self::expandVariables( $expected );
- $this->assertEquals( $expected, $client->getHeadHtml( false ) );
+ $this->assertEquals( $expected, $client->getHeadHtml() );
}
/**
@@ -237,7 +254,26 @@ class ResourceLoaderClientHtmlTest extends PHPUnit\Framework\TestCase {
. '';
// phpcs:enable
- $this->assertEquals( $expected, $client->getHeadHtml( false ) );
+ $this->assertEquals( $expected, $client->getHeadHtml() );
+ }
+
+ /**
+ * Confirm that 'safemode' is passed down to startup.
+ *
+ * @covers ResourceLoaderClientHtml::getHeadHtml
+ */
+ public function testGetHeadHtmlWithSafemode() {
+ $client = new ResourceLoaderClientHtml(
+ self::makeContext(),
+ [ 'safemode' => '1' ]
+ );
+
+ // phpcs:disable Generic.Files.LineLength
+ $expected = '' . "\n"
+ . '';
+ // phpcs:enable
+
+ $this->assertEquals( $expected, $client->getHeadHtml() );
}
/**
@@ -256,7 +292,7 @@ class ResourceLoaderClientHtmlTest extends PHPUnit\Framework\TestCase {
. '';
// phpcs:enable
- $this->assertEquals( $expected, $client->getHeadHtml( false ) );
+ $this->assertEquals( $expected, $client->getHeadHtml() );
}
/**
@@ -267,18 +303,23 @@ class ResourceLoaderClientHtmlTest extends PHPUnit\Framework\TestCase {
$context = self::makeContext();
$context->getResourceLoader()->register( self::makeSampleModules() );
- $client = new ResourceLoaderClientHtml( $context );
+ $client = new ResourceLoaderClientHtml( $context, [ 'nonce' => false ] );
$client->setConfig( [ 'key' => 'value' ] );
$client->setModules( [
'test',
'test.private.bottom',
] );
+ $client->setModuleStyles( [
+ 'test.styles.deprecated',
+ ] );
$client->setModuleScripts( [
'test.scripts',
] );
-
- $expected = '';
- $expected = self::expandVariables( $expected );
+ // phpcs:disable Generic.Files.LineLength
+ $expected = '';
+ // phpcs:enable
$this->assertEquals( $expected, $client->getBodyHtml() );
}