extend Dummy user and group implementation to pass tests
This commit is contained in:
parent
553c2ad33a
commit
f3ecf819ec
|
@ -143,8 +143,17 @@ class OC_Group_Dummy extends OC_Group_Backend {
|
|||
* @return array an array of group names
|
||||
*/
|
||||
public function getGroups($search = '', $limit = -1, $offset = 0) {
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all users in a group
|
||||
|
@ -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])) {
|
||||
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,8 +190,17 @@ class OC_Group_Dummy extends OC_Group_Backend {
|
|||
*/
|
||||
public function countUsersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
|
||||
if(isset($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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -105,8 +105,17 @@ class OC_User_Dummy extends OC_User_Backend {
|
|||
* Get a list of all users.
|
||||
*/
|
||||
public function getUsers($search = '', $limit = null, $offset = null) {
|
||||
if(empty($search)) {
|
||||
return array_keys($this->users);
|
||||
}
|
||||
$result = array();
|
||||
foreach($this->users as $user) {
|
||||
if(stripos($user, $search) !== false) {
|
||||
$result[] = $user;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if a user exists
|
||||
|
|
|
@ -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() {
|
||||
public function getGroupName($name = null) {
|
||||
if(is_null($name)) {
|
||||
return uniqid('test_');
|
||||
} else {
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue