2014-09-23 22:41:03 +00:00
|
|
|
<?php
|
|
|
|
|
|
2015-12-07 16:26:16 +00:00
|
|
|
class JavaScriptContentHandlerTest extends MediaWikiLangTestCase {
|
2014-09-23 22:41:03 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideMakeRedirectContent
|
|
|
|
|
* @covers JavaScriptContentHandler::makeRedirectContent
|
|
|
|
|
*/
|
|
|
|
|
public function testMakeRedirectContent( $title, $expected ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->setMwGlobals( [
|
2014-09-23 22:41:03 +00:00
|
|
|
'wgServer' => '//example.org',
|
|
|
|
|
'wgScript' => '/w/index.php',
|
2016-02-17 09:09:32 +00:00
|
|
|
] );
|
2014-09-23 22:41:03 +00:00
|
|
|
$ch = new JavaScriptContentHandler();
|
|
|
|
|
$content = $ch->makeRedirectContent( Title::newFromText( $title ) );
|
2018-01-13 00:02:09 +00:00
|
|
|
$this->assertInstanceOf( JavaScriptContent::class, $content );
|
2014-09-23 22:41:03 +00:00
|
|
|
$this->assertEquals( $expected, $content->serialize( CONTENT_FORMAT_JAVASCRIPT ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Keep this in sync with JavaScriptContentTest::provideGetRedirectTarget()
|
|
|
|
|
*/
|
|
|
|
|
public static function provideMakeRedirectContent() {
|
2018-01-01 13:10:16 +00:00
|
|
|
// phpcs:disable Generic.Files.LineLength
|
2016-03-19 01:05:19 +00:00
|
|
|
return [
|
|
|
|
|
[
|
|
|
|
|
'MediaWiki:MonoBook.js',
|
|
|
|
|
'/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=MediaWiki:MonoBook.js\u0026action=raw\u0026ctype=text/javascript");'
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'User:FooBar/common.js',
|
|
|
|
|
'/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=User:FooBar/common.js\u0026action=raw\u0026ctype=text/javascript");'
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'Gadget:FooBaz.js',
|
|
|
|
|
'/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=Gadget:FooBaz.js\u0026action=raw\u0026ctype=text/javascript");'
|
|
|
|
|
],
|
|
|
|
|
];
|
2018-01-01 13:10:16 +00:00
|
|
|
// phpcs:enable
|
2014-09-23 22:41:03 +00:00
|
|
|
}
|
|
|
|
|
}
|