Merge "Fix RevisionStorageTest with non-wikitext NS_MAIN"
[lhc/web/wiklou.git] / tests / phpunit / includes / JavascriptContentTest.php
index 7a12ada..b45caa2 100644 (file)
@@ -2,8 +2,11 @@
 
 /**
  * @group ContentHandler
+ *
+ * @group Database
+ *        ^--- needed, because we do need the database to test link updates
  */
-class JavascriptContentTest extends WikitextContentTest {
+class JavascriptContentTest extends TextContentTest {
 
        public function newContent( $text ) {
                return new JavascriptContent( $text );
@@ -12,7 +15,8 @@ class JavascriptContentTest extends WikitextContentTest {
 
        public function dataGetParserOutput() {
                return array(
-                       array("hello <world>\n", "<pre class=\"mw-code mw-js\" dir=\"ltr\">\nhello &lt;world&gt;\n\n</pre>\n"),
+                       array("MediaWiki:Test.js", null, "hello <world>\n",
+                                       "<pre class=\"mw-code mw-js\" dir=\"ltr\">\nhello &lt;world&gt;\n\n</pre>"),
                        // @todo: more...?
                );
        }
@@ -76,13 +80,14 @@ class JavascriptContentTest extends WikitextContentTest {
                $this->assertTrue( $content->equals( $c ) );
        }
 
+       // XXX: currently, preSaveTransform is applied to scripts. this may change or become optional.
        public function dataPreSaveTransform() {
                return array(
                        array( 'hello this is ~~~',
-                              "hello this is ~~~",
+                               "hello this is [[Special:Contributions/127.0.0.1|127.0.0.1]]",
                        ),
                        array( 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
-                              'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
+                               'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
                        ),
                );
        }
@@ -210,6 +215,22 @@ class JavascriptContentTest extends WikitextContentTest {
                );
        }
 
+       public function testMatchMagicWord( ) {
+               $mw = MagicWord::get( "staticredirect" );
+
+               $content = $this->newContent( "#REDIRECT [[FOO]]\n__STATICREDIRECT__" );
+               $this->assertFalse( $content->matchMagicWord( $mw ), "should not have matched magic word, since it's not wikitext" );
+       }
+
+       public function testUpdateRedirect( ) {
+               $target = Title::newFromText( "testUpdateRedirect_target" );
+
+               $content = $this->newContent( "#REDIRECT [[Someplace]]" );
+               $newContent = $content->updateRedirect( $target );
+
+               $this->assertTrue( $content->equals( $newContent ), "content should be unchanged since it's not wikitext" );
+       }
+
        # =================================================================================================================
 
        public function testGetModel() {