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/filebackend/FileBackendTest.php       | 52 +++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)

(limited to 'tests/phpunit/includes/filebackend/FileBackendTest.php')

diff --git a/tests/phpunit/includes/filebackend/FileBackendTest.php b/tests/phpunit/includes/filebackend/FileBackendTest.php
index bfca75ad..2e4942f0 100644
--- a/tests/phpunit/includes/filebackend/FileBackendTest.php
+++ b/tests/phpunit/includes/filebackend/FileBackendTest.php
@@ -2376,7 +2376,7 @@ class FileBackendTest extends MediaWikiTestCase {
 
 		$status = Status::newGood();
 		$sl = $this->backend->getScopedFileLocks( $paths, LockManager::LOCK_EX, $status );
-		$this->assertType( 'ScopedLock', $sl,
+		$this->assertInstanceOf( 'ScopedLock', $sl,
 			"Scoped locking of files succeeded ($backendName)." );
 		$this->assertEquals( array(), $status->errors,
 			"Scoped locking of files succeeded ($backendName)." );
@@ -2392,6 +2392,56 @@ class FileBackendTest extends MediaWikiTestCase {
 			"Scoped unlocking of files succeeded with OK status ($backendName)." );
 	}
 
+	public function testReadAffinity() {
+		$be = TestingAccessWrapper::newFromObject(
+			new FileBackendMultiWrite( array(
+				'name' => 'localtesting',
+				'wikiId' => wfWikiId() . mt_rand(),
+				'backends' => array(
+					array( // backend 0
+						'name' => 'multitesting0',
+						'class' => 'MemoryFileBackend',
+						'isMultiMaster' => false,
+						'readAffinity' => true
+					),
+					array( // backend 1
+						'name' => 'multitesting1',
+						'class' => 'MemoryFileBackend',
+						'isMultiMaster' => true
+					)
+				)
+			) )
+		);
+
+		$this->assertEquals(
+			1,
+			$be->getReadIndexFromParams( array( 'latest' => 1 ) ),
+			'Reads with "latest" flag use backend 1'
+		);
+		$this->assertEquals(
+			0,
+			$be->getReadIndexFromParams( array( 'latest' => 0 ) ),
+			'Reads without "latest" flag use backend 0'
+		);
+
+		$p = 'container/test-cont/file.txt';
+		$be->backends[0]->quickCreate( array(
+			'dst' => "mwstore://multitesting0/$p", 'content' => 'cattitude' ) );
+		$be->backends[1]->quickCreate( array(
+			'dst' => "mwstore://multitesting1/$p", 'content' => 'princess of power' ) );
+
+		$this->assertEquals(
+			'cattitude',
+			$be->getFileContents( array( 'src' => "mwstore://localtesting/$p" ) ),
+			"Non-latest read came from backend 0"
+		);
+		$this->assertEquals(
+			'princess of power',
+			$be->getFileContents( array( 'src' => "mwstore://localtesting/$p", 'latest' => 1 ) ),
+			"Latest read came from backend1"
+		);
+	}
+
 	// helper function
 	private function listToArray( $iter ) {
 		return is_array( $iter ) ? $iter : iterator_to_array( $iter );
-- 
cgit v1.2.3-54-g00ecf