Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / includes / content / JavaScriptContentHandlerTest.php
blob0bee310227dc8288a6c2214d885a60d7bd8dbd4b
1 <?php
3 use MediaWiki\Content\JavaScriptContent;
4 use MediaWiki\Content\JavaScriptContentHandler;
5 use MediaWiki\MainConfigNames;
6 use MediaWiki\Title\Title;
8 /**
9 * @covers \MediaWiki\Content\JavaScriptContentHandler
11 class JavaScriptContentHandlerTest extends MediaWikiLangTestCase {
13 /**
14 * @dataProvider provideMakeRedirectContent
16 public function testMakeRedirectContent( $title, $expected ) {
17 $this->overrideConfigValues( [
18 MainConfigNames::Server => '//example.org',
19 MainConfigNames::Script => '/w/index.php',
20 ] );
21 $ch = new JavaScriptContentHandler();
22 $content = $ch->makeRedirectContent( Title::newFromText( $title ) );
23 $this->assertInstanceOf( JavaScriptContent::class, $content );
24 $this->assertEquals( $expected, $content->serialize( CONTENT_FORMAT_JAVASCRIPT ) );
27 /**
28 * This is re-used by JavaScriptContentTest to assert roundtrip
30 public static function provideMakeRedirectContent() {
31 return [
32 'MediaWiki namespace page' => [
33 'MediaWiki:MonoBook.js',
34 '/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=MediaWiki:MonoBook.js&action=raw&ctype=text/javascript");'
36 'User subpage' => [
37 'User:FooBar/common.js',
38 '/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=User:FooBar/common.js&action=raw&ctype=text/javascript");'
40 'Gadget page' => [
41 'Gadget:FooBaz.js',
42 '/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=Gadget:FooBaz.js&action=raw&ctype=text/javascript");'
44 'Unicode basename' => [
45 'User:😂/unicode.js',
46 '/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=User:%F0%9F%98%82/unicode.js&action=raw&ctype=text/javascript");'
48 'Ampersand basename' => [
49 'User:Penn & Teller/ampersand.js',
50 '/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=User:Penn_%26_Teller/ampersand.js&action=raw&ctype=text/javascript");'