Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4100440
JavaScriptContentHandlerTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
JavaScriptContentHandlerTest.php
View Options
<?php
use
MediaWiki\Content\JavaScriptContent
;
use
MediaWiki\Content\JavaScriptContentHandler
;
use
MediaWiki\MainConfigNames
;
use
MediaWiki\Title\Title
;
/**
* @covers \MediaWiki\Content\JavaScriptContentHandler
*/
class
JavaScriptContentHandlerTest
extends
MediaWikiLangTestCase
{
/**
* @dataProvider provideMakeRedirectContent
*/
public
function
testMakeRedirectContent
(
$title
,
$expected
)
{
$this
->
overrideConfigValues
(
[
MainConfigNames
::
Server
=>
'//example.org'
,
MainConfigNames
::
Script
=>
'/w/index.php'
,
]
);
$ch
=
new
JavaScriptContentHandler
();
$content
=
$ch
->
makeRedirectContent
(
Title
::
newFromText
(
$title
)
);
$this
->
assertInstanceOf
(
JavaScriptContent
::
class
,
$content
);
$this
->
assertEquals
(
$expected
,
$content
->
serialize
(
CONTENT_FORMAT_JAVASCRIPT
)
);
}
/**
* This is re-used by JavaScriptContentTest to assert roundtrip
*/
public
static
function
provideMakeRedirectContent
()
{
return
[
'MediaWiki namespace page'
=>
[
'MediaWiki:MonoBook.js'
,
'/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=MediaWiki:MonoBook.js&action=raw&ctype=text/javascript");'
],
'User subpage'
=>
[
'User:FooBar/common.js'
,
'/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=User:FooBar/common.js&action=raw&ctype=text/javascript");'
],
'Gadget page'
=>
[
'Gadget:FooBaz.js'
,
'/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=Gadget:FooBaz.js&action=raw&ctype=text/javascript");'
],
'Unicode basename'
=>
[
'User:😂/unicode.js'
,
'/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=User:%F0%9F%98%82/unicode.js&action=raw&ctype=text/javascript");'
],
'Ampersand basename'
=>
[
'User:Penn & Teller/ampersand.js'
,
'/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=User:Penn_%26_Teller/ampersand.js&action=raw&ctype=text/javascript");'
],
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Aug 18, 16:24 (3 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
3d/e6/a3d8da7b208c24623b71dfd59ed7
Default Alt Text
JavaScriptContentHandlerTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment