From a1789ddde42033f1b05cc4929491214ee6e79383 Mon Sep 17 00:00:00 2001
From: Pierre Schmitz <pierre@archlinux.de>
Date: Thu, 17 Dec 2015 09:15:42 +0100
Subject: Update to MediaWiki 1.26.0

---
 .../includes/content/JavaScriptContentTest.php     | 53 ++++++++++++++++++++--
 1 file changed, 48 insertions(+), 5 deletions(-)

(limited to 'tests/phpunit/includes/content/JavaScriptContentTest.php')

diff --git a/tests/phpunit/includes/content/JavaScriptContentTest.php b/tests/phpunit/includes/content/JavaScriptContentTest.php
index 7193ec9f..0ee27129 100644
--- a/tests/phpunit/includes/content/JavaScriptContentTest.php
+++ b/tests/phpunit/includes/content/JavaScriptContentTest.php
@@ -251,16 +251,31 @@ class JavaScriptContentTest extends TextContentTest {
 
 	/**
 	 * @covers JavaScriptContent::updateRedirect
+	 * @dataProvider provideUpdateRedirect
 	 */
-	public function testUpdateRedirect() {
+	public function testUpdateRedirect( $oldText, $expectedText) {
+		$this->setMwGlobals( array(
+			'wgServer' => '//example.org',
+			'wgScriptPath' => '/w/index.php',
+		) );
 		$target = Title::newFromText( "testUpdateRedirect_target" );
 
-		$content = $this->newContent( "#REDIRECT [[Someplace]]" );
+		$content = new JavaScriptContent( $oldText );
 		$newContent = $content->updateRedirect( $target );
 
-		$this->assertTrue(
-			$content->equals( $newContent ),
-			"content should be unchanged since it's not wikitext"
+		$this->assertEquals( $expectedText, $newContent->getNativeData() );
+	}
+
+	public static function provideUpdateRedirect() {
+		return array(
+			array(
+				'#REDIRECT [[Someplace]]',
+				'#REDIRECT [[Someplace]]',
+			),
+			array(
+				'/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=MediaWiki:MonoBook.js\u0026action=raw\u0026ctype=text/javascript");',
+				'/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=TestUpdateRedirect_target\u0026action=raw\u0026ctype=text/javascript");'
+			)
 		);
 	}
 
@@ -290,4 +305,32 @@ class JavaScriptContentTest extends TextContentTest {
 			array( new JavaScriptContent( "hallo" ), new JavaScriptContent( "HALLO" ), false ),
 		);
 	}
+
+	/**
+	 * @dataProvider provideGetRedirectTarget
+	 */
+	public function testGetRedirectTarget( $title, $text ) {
+		$this->setMwGlobals( array(
+			'wgServer' => '//example.org',
+			'wgScriptPath' => '/w/index.php',
+		) );
+		$content = new JavaScriptContent( $text );
+		$target = $content->getRedirectTarget();
+		$this->assertEquals( $title, $target ? $target->getPrefixedText() : null );
+	}
+
+	/**
+	 * Keep this in sync with JavaScriptContentHandlerTest::provideMakeRedirectContent()
+	 */
+	public static function provideGetRedirectTarget() {
+		return array(
+			array( 'MediaWiki:MonoBook.js', '/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=MediaWiki:MonoBook.js\u0026action=raw\u0026ctype=text/javascript");' ),
+			array( 'User:FooBar/common.js', '/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=User:FooBar/common.js\u0026action=raw\u0026ctype=text/javascript");' ),
+			array( 'Gadget:FooBaz.js', '/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=Gadget:FooBaz.js\u0026action=raw\u0026ctype=text/javascript");' ),
+			// No #REDIRECT comment
+			array( null, 'mw.loader.load("//example.org/w/index.php?title=MediaWiki:NoRedirect.js\u0026action=raw\u0026ctype=text/javascript");' ),
+			// Different domain
+			array( null, '/* #REDIRECT */mw.loader.load("//example.com/w/index.php?title=MediaWiki:OtherWiki.js\u0026action=raw\u0026ctype=text/javascript");' ),
+		);
+	}
 }
-- 
cgit v1.2.3-54-g00ecf