[Pkg-owncloud-commits] [owncloud] 160/258: fix unit tests

David Prévot taffit at moszumanska.debian.org
Sat Oct 11 17:22:32 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 aab44694ad284e81b949a896e129d0488569d779
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date:   Wed Aug 27 00:31:49 2014 +0200

    fix unit tests
---
 tests/lib/share/backend.php | 23 ++++++++++++++++++++---
 tests/lib/share/share.php   |  4 ++--
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/tests/lib/share/backend.php b/tests/lib/share/backend.php
index 420bd9d..50ce24e 100644
--- a/tests/lib/share/backend.php
+++ b/tests/lib/share/backend.php
@@ -38,19 +38,36 @@ class Test_Share_Backend implements OCP\Share_Backend {
 
 	public function generateTarget($itemSource, $shareWith, $exclude = null) {
 		// Always make target be test.txt to cause conflicts
-		$target = 'test.txt';
-		if (isset($exclude)) {
+
+		if (substr($itemSource, 0, strlen('test')) !== 'test') {
+			$target = "test.txt";
+		} else {
+			$target = $itemSource;
+		}
+
+
+		$shares = \OCP\Share::getItemsSharedWithUser('test', $shareWith);
+
+		$knownTargets = array();
+		foreach ($shares as $share) {
+			$knownTargets[] = $share['item_target'];
+		}
+
+
+		if (in_array($target, $knownTargets)) {
 			$pos = strrpos($target, '.');
 			$name = substr($target, 0, $pos);
 			$ext = substr($target, $pos);
 			$append = '';
 			$i = 1;
-			while (in_array($name.$append.$ext, $exclude)) {
+			while (in_array($name.$append.$ext, $knownTargets)) {
 				$append = $i;
 				$i++;
 			}
 			$target = $name.$append.$ext;
+
 		}
+
 		return $target;
 	}
 
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index a0b3643..fbff895 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -48,8 +48,8 @@ class Test_Share extends PHPUnit_Framework_TestCase {
 		OC_User::setUserId($this->user1);
 		OC_Group::clearBackends();
 		OC_Group::useBackend(new OC_Group_Dummy);
-		$this->group1 = uniqid('group_');
-		$this->group2 = uniqid('group_');
+		$this->group1 = uniqid('group1_');
+		$this->group2 = uniqid('group2_');
 		OC_Group::createGroup($this->group1);
 		OC_Group::createGroup($this->group2);
 		OC_Group::addToGroup($this->user1, $this->group1);

-- 
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