MediaWiki
REL1_21
|
00001 <?php 00002 00008 class CssContentTest extends MediaWikiTestCase { 00009 00010 protected function setUp() { 00011 parent::setUp(); 00012 00013 // Anon user 00014 $user = new User(); 00015 $user->setName( '127.0.0.1' ); 00016 00017 $this->setMwGlobals( array( 00018 'wgUser' => $user, 00019 'wgTextModelsToParse' => array( 00020 CONTENT_MODEL_CSS, 00021 ) 00022 ) ); 00023 } 00024 00025 public function newContent( $text ) { 00026 return new CssContent( $text ); 00027 } 00028 00029 public static function dataGetParserOutput() { 00030 return array( 00031 array( 00032 'MediaWiki:Test.css', 00033 null, 00034 "hello <world>\n", 00035 "<pre class=\"mw-code mw-css\" dir=\"ltr\">\nhello <world>\n\n</pre>" 00036 ), 00037 array( 00038 'MediaWiki:Test.css', 00039 null, 00040 "/* hello [[world]] */\n", 00041 "<pre class=\"mw-code mw-css\" dir=\"ltr\">\n/* hello [[world]] */\n\n</pre>", 00042 array( 00043 'Links' => array( 00044 array( 'World' => 0 ) 00045 ) 00046 ) 00047 ), 00048 00049 // TODO: more...? 00050 ); 00051 } 00052 00053 public function testGetModel() { 00054 $content = $this->newContent( 'hello world.' ); 00055 00056 $this->assertEquals( CONTENT_MODEL_CSS, $content->getModel() ); 00057 } 00058 00059 public function testGetContentHandler() { 00060 $content = $this->newContent( 'hello world.' ); 00061 00062 $this->assertEquals( CONTENT_MODEL_CSS, $content->getContentHandler()->getModelID() ); 00063 } 00064 00065 public static function dataEquals() { 00066 return array( 00067 array( new CssContent( 'hallo' ), null, false ), 00068 array( new CssContent( 'hallo' ), new CssContent( 'hallo' ), true ), 00069 array( new CssContent( 'hallo' ), new WikitextContent( 'hallo' ), false ), 00070 array( new CssContent( 'hallo' ), new CssContent( 'HALLO' ), false ), 00071 ); 00072 } 00073 00077 public function testEquals( Content $a, Content $b = null, $equal = false ) { 00078 $this->assertEquals( $equal, $a->equals( $b ) ); 00079 } 00080 00081 }