summaryrefslogtreecommitdiffstats
path: root/tests/lib/Util
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Util')
-rw-r--r--tests/lib/Util/Group/Dummy.php57
-rw-r--r--tests/lib/Util/User/Dummy.php2
2 files changed, 29 insertions, 30 deletions
diff --git a/tests/lib/Util/Group/Dummy.php b/tests/lib/Util/Group/Dummy.php
index f75aef5737e..293c8f48945 100644
--- a/tests/lib/Util/Group/Dummy.php
+++ b/tests/lib/Util/Group/Dummy.php
@@ -45,10 +45,10 @@ class Dummy extends Backend {
* be returned.
*/
public function createGroup($gid) {
- if(!isset($this->groups[$gid])) {
+ if (!isset($this->groups[$gid])) {
$this->groups[$gid]=[];
return true;
- }else{
+ } else {
return false;
}
}
@@ -61,10 +61,10 @@ class Dummy extends Backend {
* Deletes a group and removes it from the group_user-table
*/
public function deleteGroup($gid) {
- if(isset($this->groups[$gid])) {
+ if (isset($this->groups[$gid])) {
unset($this->groups[$gid]);
return true;
- }else{
+ } else {
return false;
}
}
@@ -78,9 +78,9 @@ class Dummy extends Backend {
* Checks whether the user is member of a group or not.
*/
public function inGroup($uid, $gid) {
- if(isset($this->groups[$gid])) {
+ if (isset($this->groups[$gid])) {
return (array_search($uid, $this->groups[$gid])!==false);
- }else{
+ } else {
return false;
}
}
@@ -94,14 +94,14 @@ class Dummy extends Backend {
* Adds a user to a group.
*/
public function addToGroup($uid, $gid) {
- if(isset($this->groups[$gid])) {
- if(array_search($uid, $this->groups[$gid])===false) {
+ if (isset($this->groups[$gid])) {
+ if (array_search($uid, $this->groups[$gid])===false) {
$this->groups[$gid][]=$uid;
return true;
- }else{
+ } else {
return false;
}
- }else{
+ } else {
return false;
}
}
@@ -115,14 +115,14 @@ class Dummy extends Backend {
* removes the user from a group.
*/
public function removeFromGroup($uid, $gid) {
- if(isset($this->groups[$gid])) {
- if(($index=array_search($uid, $this->groups[$gid]))!==false) {
+ if (isset($this->groups[$gid])) {
+ if (($index=array_search($uid, $this->groups[$gid]))!==false) {
unset($this->groups[$gid][$index]);
return true;
- }else{
+ } else {
return false;
}
- }else{
+ } else {
return false;
}
}
@@ -138,8 +138,8 @@ class Dummy extends Backend {
public function getUserGroups($uid) {
$groups=[];
$allGroups=array_keys($this->groups);
- foreach($allGroups as $group) {
- if($this->inGroup($uid, $group)) {
+ foreach ($allGroups as $group) {
+ if ($this->inGroup($uid, $group)) {
$groups[]=$group;
}
}
@@ -154,12 +154,12 @@ class Dummy extends Backend {
* @return array an array of group names
*/
public function getGroups($search = '', $limit = -1, $offset = 0) {
- if(empty($search)) {
+ if (empty($search)) {
return array_keys($this->groups);
}
$result = [];
- foreach(array_keys($this->groups) as $group) {
- if(stripos($group, $search) !== false) {
+ foreach (array_keys($this->groups) as $group) {
+ if (stripos($group, $search) !== false) {
$result[] = $group;
}
}
@@ -175,19 +175,19 @@ class Dummy extends Backend {
* @return array an array of user IDs
*/
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
- if(isset($this->groups[$gid])) {
- if(empty($search)) {
+ if (isset($this->groups[$gid])) {
+ if (empty($search)) {
$length = $limit < 0 ? null : $limit;
return array_slice($this->groups[$gid], $offset, $length);
}
$result = [];
- foreach($this->groups[$gid] as $user) {
- if(stripos($user, $search) !== false) {
+ foreach ($this->groups[$gid] as $user) {
+ if (stripos($user, $search) !== false) {
$result[] = $user;
}
}
return $result;
- }else{
+ } else {
return [];
}
}
@@ -201,18 +201,17 @@ class Dummy extends Backend {
* @return int
*/
public function countUsersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
- if(isset($this->groups[$gid])) {
- if(empty($search)) {
+ 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) {
+ foreach ($this->groups[$gid] as $user) {
+ if (stripos($user, $search) !== false) {
$count++;
}
}
return $count;
}
}
-
}
diff --git a/tests/lib/Util/User/Dummy.php b/tests/lib/Util/User/Dummy.php
index 3e6372ca033..478b7599701 100644
--- a/tests/lib/Util/User/Dummy.php
+++ b/tests/lib/Util/User/Dummy.php
@@ -109,7 +109,7 @@ class Dummy extends Backend implements \OCP\IUserBackend {
}
public function loginName2UserName($loginName) {
- if(isset($this->users[strtolower($loginName)])) {
+ if (isset($this->users[strtolower($loginName)])) {
return strtolower($loginName);
}
return false;