X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fresourceloader%2FResourceLoaderClientHtmlTest.php;h=7cd698354d1b5c64176bbe1866f3323fa9040c60;hb=7bfc0f42a305ebd7b1f762edc292a04f0bf72950;hp=ea3d199efe905bc399b55844aafb3162e7291db3;hpb=6c3b72e3e90df4eed1487958f4178cd7c0c7bfad;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php index ea3d199efe..7cd698354d 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,12 +224,12 @@ class ResourceLoaderClientHtmlTest extends PHPUnit\Framework\TestCase { $expected = '' . "\n" . '' . "\n" - . '' . "\n" + . '' . "\n" . '' . "\n" . ''; // phpcs:enable @@ -240,6 +257,25 @@ class ResourceLoaderClientHtmlTest extends PHPUnit\Framework\TestCase { $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() ); + } + /** * Confirm that a null 'target' is the same as no target. * @@ -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() ); } @@ -408,7 +449,7 @@ class ResourceLoaderClientHtmlTest extends PHPUnit\Framework\TestCase { public function testMakeLoad( array $extraQuery, array $modules, $type, $expected ) { $context = self::makeContext( $extraQuery ); $context->getResourceLoader()->register( self::makeSampleModules() ); - $actual = ResourceLoaderClientHtml::makeLoad( $context, $modules, $type, $extraQuery ); + $actual = ResourceLoaderClientHtml::makeLoad( $context, $modules, $type, $extraQuery, false ); $expected = self::expandVariables( $expected ); $this->assertEquals( $expected, (string)$actual ); }