MediaWiki REL1_31
JavaScriptContentHandlerTest.php
Go to the documentation of this file.
1<?php
2
4
9 public function testMakeRedirectContent( $title, $expected ) {
10 $this->setMwGlobals( [
11 'wgServer' => '//example.org',
12 'wgScript' => '/w/index.php',
13 ] );
14 $ch = new JavaScriptContentHandler();
15 $content = $ch->makeRedirectContent( Title::newFromText( $title ) );
16 $this->assertInstanceOf( JavaScriptContent::class, $content );
17 $this->assertEquals( $expected, $content->serialize( CONTENT_FORMAT_JAVASCRIPT ) );
18 }
19
23 public static function provideMakeRedirectContent() {
24 // phpcs:disable Generic.Files.LineLength
25 return [
26 [
27 'MediaWiki:MonoBook.js',
28 '/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=MediaWiki:MonoBook.js\u0026action=raw\u0026ctype=text/javascript");'
29 ],
30 [
31 'User:FooBar/common.js',
32 '/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=User:FooBar/common.js\u0026action=raw\u0026ctype=text/javascript");'
33 ],
34 [
35 'Gadget:FooBaz.js',
36 '/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=Gadget:FooBaz.js\u0026action=raw\u0026ctype=text/javascript");'
37 ],
38 ];
39 // phpcs:enable
40 }
41}
testMakeRedirectContent( $title, $expected)
provideMakeRedirectContent JavaScriptContentHandler::makeRedirectContent
static provideMakeRedirectContent()
Keep this in sync with JavaScriptContentTest::provideGetRedirectTarget()
Content handler for JavaScript pages.
Base class that store and restore the Language objects.
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
const CONTENT_FORMAT_JAVASCRIPT
Definition Defines.php:262