[Pkg-owncloud-commits] [owncloud] 43/273: extend Dummy user and group implementation to pass tests

David Prévot taffit at moszumanska.debian.org
Fri Jul 4 03:12:56 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 f3ecf819ec8e6841be62603c3e8a1e255fc6522d
Author: Arthur Schiwon <blizzz at owncloud.com>
Date:   Wed Jun 25 13:13:53 2014 +0200

    extend Dummy user and group implementation to pass tests
---
 lib/private/group/dummy.php | 33 ++++++++++++++++++++++++++++++---
 lib/private/user/dummy.php  | 11 ++++++++++-
 tests/lib/group/backend.php |  8 ++++++--
 3 files changed, 46 insertions(+), 6 deletions(-)

diff --git a/lib/private/group/dummy.php b/lib/private/group/dummy.php
index e48c6a0..4af18b2 100644
--- a/lib/private/group/dummy.php
+++ b/lib/private/group/dummy.php
@@ -143,7 +143,16 @@ class OC_Group_Dummy extends OC_Group_Backend {
 	 * @return array an array of group names
 	 */
 	public function getGroups($search = '', $limit = -1, $offset = 0) {
-		return array_keys($this->groups);
+		if(empty($search)) {
+			return array_keys($this->groups);
+		}
+		$result = array();
+		foreach(array_keys($this->groups) as $group) {
+			if(stripos($group, $search) !== false) {
+				$result[] = $group;
+			}
+		}
+		return $result;
 	}
 
 	/**
@@ -156,7 +165,16 @@ class OC_Group_Dummy extends OC_Group_Backend {
 	 */
 	public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
 		if(isset($this->groups[$gid])) {
-			return $this->groups[$gid];
+			if(empty($search)) {
+				return $this->groups[$gid];
+			}
+			$result = array();
+			foreach($this->groups[$gid] as $user) {
+				if(stripos($user, $search) !== false) {
+					$result[] = $user;
+				}
+			}
+			return $result;
 		}else{
 			return array();
 		}
@@ -172,7 +190,16 @@ class OC_Group_Dummy extends OC_Group_Backend {
 	 */
 	public function countUsersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
 		if(isset($this->groups[$gid])) {
-			return count($this->groups[$gid]);
+			if(empty($search)) {
+				return count($this->groups[$gid]);
+			}
+			$count = 0;
+			foreach($this->groups[$gid] as $user) {
+				if(stripos($user, $search) !== false) {
+					$count++;
+				}
+			}
+			return $count;
 		}
 	}
 
diff --git a/lib/private/user/dummy.php b/lib/private/user/dummy.php
index 7761680..1d20bd3 100644
--- a/lib/private/user/dummy.php
+++ b/lib/private/user/dummy.php
@@ -105,7 +105,16 @@ class OC_User_Dummy extends OC_User_Backend {
 	 * Get a list of all users.
 	 */
 	public function getUsers($search = '', $limit = null, $offset = null) {
-		return array_keys($this->users);
+		if(empty($search)) {
+			return array_keys($this->users);
+		}
+		$result = array();
+		foreach($this->users as $user) {
+			if(stripos($user, $search) !== false) {
+				$result[] = $user;
+			}
+		}
+		return $result;
 	}
 
 	/**
diff --git a/tests/lib/group/backend.php b/tests/lib/group/backend.php
index 34442fa..95a5cf5 100644
--- a/tests/lib/group/backend.php
+++ b/tests/lib/group/backend.php
@@ -31,8 +31,12 @@ abstract class Test_Group_Backend extends PHPUnit_Framework_TestCase {
 	 * test cases can override this in order to clean up created groups
 	 * @return string
 	 */
-	public function getGroupName() {
-		return uniqid('test_');
+	public function getGroupName($name = null) {
+		if(is_null($name)) {
+			return uniqid('test_');
+		} else {
+			return $name;
+		}
 	}
 
 	/**

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