[Pkg-owncloud-commits] [owncloud] 115/153: Fix priority merging logic and add unit test

David Prévot taffit at moszumanska.debian.org
Tue May 27 03:05:44 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 0a8a3199158a7a52c071054df4b4d740c90db5ac
Author: Robin McCorkell <rmccorkell at karoshi.org.uk>
Date:   Wed May 14 22:34:38 2014 +0100

    Fix priority merging logic and add unit test
---
 apps/files_external/lib/config.php        |  7 +++++
 apps/files_external/tests/mountconfig.php | 48 +++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)

diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index 788a136..d47a2b4 100755
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -769,6 +769,13 @@ class OC_Mount_Config {
 		$mountPath = key($mountPoint[$applicable]);
 		if (isset($data[$mountType])) {
 			if (isset($data[$mountType][$applicable])) {
+				// Merge priorities
+				if (isset($data[$mountType][$applicable][$mountPath])
+					&& isset($data[$mountType][$applicable][$mountPath]['priority'])
+					&& !isset($mountPoint[$applicable][$mountPath]['priority'])) {
+					$mountPoint[$applicable][$mountPath]['priority']
+						= $data[$mountType][$applicable][$mountPath]['priority'];
+				}
 				$data[$mountType][$applicable]
 					= array_merge($data[$mountType][$applicable], $mountPoint[$applicable]);
 			} else {
diff --git a/apps/files_external/tests/mountconfig.php b/apps/files_external/tests/mountconfig.php
index 33cbd10..9b04e20 100644
--- a/apps/files_external/tests/mountconfig.php
+++ b/apps/files_external/tests/mountconfig.php
@@ -752,4 +752,52 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
 		$this->assertEquals(1, count($mountPoints));
 		$this->assertEquals($expected, $mountPoints['/'.self::TEST_USER1.'/files/ext']['options']['id']);
 	}
+
+	/**
+	 * Test for persistence of priority when changing mount options
+	 */
+	public function testPriorityPersistence() {
+		$class = '\OC\Files\Storage\SMB';
+		$priority = 123;
+		$mountConfig = array(
+			'host' => 'somehost',
+			'user' => 'someuser',
+			'password' => 'somepassword',
+			'root' => 'someroot'
+		);
+
+		$this->assertTrue(
+			OC_Mount_Config::addMountPoint(
+				'/ext',
+				$class,
+				$mountConfig,
+				OC_Mount_Config::MOUNT_TYPE_USER,
+				self::TEST_USER1,
+				false,
+				$priority
+			)
+		);
+
+		// Check for correct priority
+		$mountPoints = OC_Mount_Config::getAbsoluteMountPoints(self::TEST_USER1);
+		$this->assertEquals($priority,
+			$mountPoints['/'.self::TEST_USER1.'/files/ext']['priority']);
+
+		// Simulate changed mount options (without priority set)
+		$this->assertTrue(
+			OC_Mount_Config::addMountPoint(
+				'/ext',
+				$class,
+				$mountConfig,
+				OC_Mount_Config::MOUNT_TYPE_USER,
+				self::TEST_USER1,
+				false
+			)
+		);
+
+		// Check for correct priority
+		$mountPoints = OC_Mount_Config::getAbsoluteMountPoints(self::TEST_USER1);
+		$this->assertEquals($priority,
+			$mountPoints['/'.self::TEST_USER1.'/files/ext']['priority']);
+	}
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list