When a JavaScript page is moved, a "redirect" in the form of mw.loader.load(...) will be left behind, so any other JavaScript loading the page that way will still work, albeit with an extra HTTP request. This also implements Content::getRedirectTarget(), so redirects are marked properly in the database, and users viewing them are redirected properly. A magic "/* #REDIRECT */" comment must be in front of the mw.loader.load call. This is done so that pages which currently are just one mw.loader.load call aren't turned into redirects. Bug: 71200 Bug: 33973 Change-Id: I10fdff087a901da56fad64531f0e382f90ebcf37
110 lines
2.4 KiB
PHP
110 lines
2.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group ContentHandler
|
|
* @group Database
|
|
* ^--- needed, because we do need the database to test link updates
|
|
*
|
|
* @FIXME this should not extend JavaScriptContentTest.
|
|
*/
|
|
class CssContentTest extends JavaScriptContentTest {
|
|
|
|
protected function setUp() {
|
|
parent::setUp();
|
|
|
|
// Anon user
|
|
$user = new User();
|
|
$user->setName( '127.0.0.1' );
|
|
|
|
$this->setMwGlobals( array(
|
|
'wgUser' => $user,
|
|
'wgTextModelsToParse' => array(
|
|
CONTENT_MODEL_CSS,
|
|
)
|
|
) );
|
|
}
|
|
|
|
public function newContent( $text ) {
|
|
return new CssContent( $text );
|
|
}
|
|
|
|
public static function dataGetParserOutput() {
|
|
return array(
|
|
array(
|
|
'MediaWiki:Test.css',
|
|
null,
|
|
"hello <world>\n",
|
|
"<pre class=\"mw-code mw-css\" dir=\"ltr\">\nhello <world>\n\n</pre>"
|
|
),
|
|
array(
|
|
'MediaWiki:Test.css',
|
|
null,
|
|
"/* hello [[world]] */\n",
|
|
"<pre class=\"mw-code mw-css\" dir=\"ltr\">\n/* hello [[world]] */\n\n</pre>",
|
|
array(
|
|
'Links' => array(
|
|
array( 'World' => 0 )
|
|
)
|
|
)
|
|
),
|
|
|
|
// TODO: more...?
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @covers CssContent::getModel
|
|
*/
|
|
public function testGetModel() {
|
|
$content = $this->newContent( 'hello world.' );
|
|
|
|
$this->assertEquals( CONTENT_MODEL_CSS, $content->getModel() );
|
|
}
|
|
|
|
/**
|
|
* @covers CssContent::getContentHandler
|
|
*/
|
|
public function testGetContentHandler() {
|
|
$content = $this->newContent( 'hello world.' );
|
|
|
|
$this->assertEquals( CONTENT_MODEL_CSS, $content->getContentHandler()->getModelID() );
|
|
}
|
|
|
|
/**
|
|
* Redirects aren't supported
|
|
*/
|
|
public static function provideUpdateRedirect() {
|
|
return array(
|
|
array(
|
|
'#REDIRECT [[Someplace]]',
|
|
'#REDIRECT [[Someplace]]',
|
|
),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Override this since CssContent does not support redirects yet
|
|
*/
|
|
public static function provideGetRedirectTarget() {
|
|
return array(
|
|
array( null, '' ),
|
|
);
|
|
}
|
|
|
|
public static function dataEquals() {
|
|
return array(
|
|
array( new CssContent( 'hallo' ), null, false ),
|
|
array( new CssContent( 'hallo' ), new CssContent( 'hallo' ), true ),
|
|
array( new CssContent( 'hallo' ), new WikitextContent( 'hallo' ), false ),
|
|
array( new CssContent( 'hallo' ), new CssContent( 'HALLO' ), false ),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @dataProvider dataEquals
|
|
* @covers CssContent::equals
|
|
*/
|
|
public function testEquals( Content $a, Content $b = null, $equal = false ) {
|
|
$this->assertEquals( $equal, $a->equals( $b ) );
|
|
}
|
|
}
|