2929
3030namespace Test \Util \Group ;
3131
32- use OC \Group \Backend ;
32+ use OCP \Group \Backend \ABackend ;
33+ use OCP \Group \Backend \IDeleteGroupBackend ;
34+ use OCP \Group \Backend \IAddToGroupBackend ;
35+ use OCP \Group \Backend \IRemoveFromGroupBackend ;
36+ use OCP \Group \Backend \ICreateGroupBackend ;
37+ use OCP \Group \Backend \ICountUsersBackend ;
3338
3439/**
35- * dummy group backend, does not keep state, only for testing use
40+ * Dummy group backend, does not keep state, only for testing use
3641 */
37- class Dummy extends Backend {
42+ class Dummy extends ABackend implements ICreateGroupBackend, IDeleteGroupBackend, IAddToGroupBackend, IRemoveFromGroupBackend, ICountUsersBackend {
3843 private $ groups = [];
3944 /**
4045 * Try to create a new group
@@ -44,7 +49,7 @@ class Dummy extends Backend {
4449 * Tries to create a new group. If the group name already exists, false will
4550 * be returned.
4651 */
47- public function createGroup ($ gid ) {
52+ public function createGroup (string $ gid ): bool {
4853 if (!isset ($ this ->groups [$ gid ])) {
4954 $ this ->groups [$ gid ] = [];
5055 return true ;
@@ -60,7 +65,7 @@ public function createGroup($gid) {
6065 *
6166 * Deletes a group and removes it from the group_user-table
6267 */
63- public function deleteGroup ($ gid ) {
68+ public function deleteGroup (string $ gid ): bool {
6469 if (isset ($ this ->groups [$ gid ])) {
6570 unset($ this ->groups [$ gid ]);
6671 return true ;
@@ -93,7 +98,7 @@ public function inGroup($uid, $gid) {
9398 *
9499 * Adds a user to a group.
95100 */
96- public function addToGroup ($ uid , $ gid ) {
101+ public function addToGroup (string $ uid , string $ gid ): bool {
97102 if (isset ($ this ->groups [$ gid ])) {
98103 if (array_search ($ uid , $ this ->groups [$ gid ]) === false ) {
99104 $ this ->groups [$ gid ][] = $ uid ;
@@ -114,7 +119,7 @@ public function addToGroup($uid, $gid) {
114119 *
115120 * removes the user from a group.
116121 */
117- public function removeFromGroup ($ uid , $ gid ) {
122+ public function removeFromGroup (string $ uid , string $ gid ): bool {
118123 if (isset ($ this ->groups [$ gid ])) {
119124 if (($ index = array_search ($ uid , $ this ->groups [$ gid ])) !== false ) {
120125 unset($ this ->groups [$ gid ][$ index ]);
@@ -200,7 +205,7 @@ public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
200205 * @param int $offset
201206 * @return int
202207 */
203- public function countUsersInGroup ($ gid , $ search = '' , $ limit = - 1 , $ offset = 0 ) {
208+ public function countUsersInGroup (string $ gid , string $ search = '' ): int {
204209 if (isset ($ this ->groups [$ gid ])) {
205210 if (empty ($ search )) {
206211 return count ($ this ->groups [$ gid ]);
@@ -213,5 +218,10 @@ public function countUsersInGroup($gid, $search = '', $limit = -1, $offset = 0)
213218 }
214219 return $ count ;
215220 }
221+ return 0 ;
222+ }
223+
224+ public function groupExists ($ gid ) {
225+ return isset ($ this ->groups [$ gid ]);
216226 }
217227}
0 commit comments