From 97d31946c3d4cfdac46f91385b3d888fde30d934 Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Sat, 3 Jan 2015 13:25:48 +0000 Subject: [PATCH 1/3] Ensure admin group is present before running tests --- apps/provisioning_api/lib/groups.php | 5 +++++ apps/provisioning_api/lib/users.php | 2 +- apps/provisioning_api/tests/groupsTest.php | 2 -- apps/provisioning_api/tests/usersTest.php | 5 ++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/provisioning_api/lib/groups.php b/apps/provisioning_api/lib/groups.php index 4440c5bf50..ca714f7cc3 100644 --- a/apps/provisioning_api/lib/groups.php +++ b/apps/provisioning_api/lib/groups.php @@ -31,6 +31,11 @@ use \OC_SubAdmin; class Groups{ + public function setUp() { + // These seems to be deleted by another test. + OC_Group::createGroup('admin'); + } + /** * returns a list of groups */ diff --git a/apps/provisioning_api/lib/users.php b/apps/provisioning_api/lib/users.php index 891264a908..4262dff7a6 100644 --- a/apps/provisioning_api/lib/users.php +++ b/apps/provisioning_api/lib/users.php @@ -70,7 +70,7 @@ class Users { // Admin? Or SubAdmin? if(OC_User::isAdminUser(OC_User::getUser()) || OC_SubAdmin::isUserAccessible(OC_User::getUser(), $userId)) { // Check they exist - if(!OC_user::userExists($userId)) { + if(!OC_User::userExists($userId)) { return new OC_OCS_Result(null, \OC_API::RESPOND_NOT_FOUND, 'The requested user could not be found'); } // Show all diff --git a/apps/provisioning_api/tests/groupsTest.php b/apps/provisioning_api/tests/groupsTest.php index 0fb6e18a3e..14d6f46dbf 100644 --- a/apps/provisioning_api/tests/groupsTest.php +++ b/apps/provisioning_api/tests/groupsTest.php @@ -145,10 +145,8 @@ class Test_Provisioning_Api_Groups extends PHPUnit_Framework_TestCase { OC_Group::deleteGroup($group1); $user1 = $this->generateUsers(); - $user2 = $this->generateUsers(); OC_User::setUserId($user1); OC_Group::addToGroup($user1, 'admin'); - $group1 = uniqid(); $result = \OCA\provisioning_api\Groups::getSubAdminsOfGroup(array( 'groupid' => uniqid(), )); diff --git a/apps/provisioning_api/tests/usersTest.php b/apps/provisioning_api/tests/usersTest.php index b464a2e5fd..34df2769b2 100644 --- a/apps/provisioning_api/tests/usersTest.php +++ b/apps/provisioning_api/tests/usersTest.php @@ -26,6 +26,10 @@ class Test_Provisioning_Api_Users extends PHPUnit_Framework_TestCase { private $users = array(); + public function setUp() { + OC_Group::createGroup('admin'); + } + /** * Generates a temp user * @param $num int number of users to generate @@ -436,7 +440,6 @@ class Test_Provisioning_Api_Users extends PHPUnit_Framework_TestCase { )); $this->assertInstanceOf('OC_OCS_Result', $result); $this->assertFalse($result->succeeded()); - $data = $result->getData(); OC_Group::deleteGroup($group); } From 5c0d7f2ee567524f0c6ab250742a51d57a91f65c Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Sat, 3 Jan 2015 15:39:42 +0000 Subject: [PATCH 2/3] Create admin group before running provisioning_api tests --- apps/provisioning_api/tests/groupsTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/provisioning_api/tests/groupsTest.php b/apps/provisioning_api/tests/groupsTest.php index 14d6f46dbf..fb1fe96e9c 100644 --- a/apps/provisioning_api/tests/groupsTest.php +++ b/apps/provisioning_api/tests/groupsTest.php @@ -27,6 +27,11 @@ class Test_Provisioning_Api_Groups extends PHPUnit_Framework_TestCase { private $users = array(); + public function setUp() { + // These seems to be deleted by another test. + OC_Group::createGroup('admin'); + } + /** * Generates a temp user * @param $num int number of users to generate From a20de1548d5eaa7298a18c223d53c6484d5f96ac Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Sat, 3 Jan 2015 15:58:36 +0000 Subject: [PATCH 3/3] Add proper group setup and teardown to all provisioning_api tests --- apps/provisioning_api/tests/AppsTest.php | 7 +++++++ apps/provisioning_api/tests/groupsTest.php | 1 + apps/provisioning_api/tests/usersTest.php | 1 + 3 files changed, 9 insertions(+) diff --git a/apps/provisioning_api/tests/AppsTest.php b/apps/provisioning_api/tests/AppsTest.php index 2a269450cc..c68259d175 100644 --- a/apps/provisioning_api/tests/AppsTest.php +++ b/apps/provisioning_api/tests/AppsTest.php @@ -27,6 +27,9 @@ class Test_Provisioning_Api_Apps extends PHPUnit_Framework_TestCase { private $users = array(); + function setUp() { + OC_Group::createGroup('admin'); + } /** * Generates a temp user * @param $num int number of users to generate @@ -98,4 +101,8 @@ class Test_Provisioning_Api_Apps extends PHPUnit_Framework_TestCase { } + function tearDown() { + OC_Group::deleteGroup('admin'); + } + } diff --git a/apps/provisioning_api/tests/groupsTest.php b/apps/provisioning_api/tests/groupsTest.php index fb1fe96e9c..280e4792ff 100644 --- a/apps/provisioning_api/tests/groupsTest.php +++ b/apps/provisioning_api/tests/groupsTest.php @@ -167,6 +167,7 @@ class Test_Provisioning_Api_Groups extends PHPUnit_Framework_TestCase { foreach($this->users as $user) { \OC_User::deleteUser($user); } + OC_Group::deleteGroup('admin'); } diff --git a/apps/provisioning_api/tests/usersTest.php b/apps/provisioning_api/tests/usersTest.php index 34df2769b2..381baa633e 100644 --- a/apps/provisioning_api/tests/usersTest.php +++ b/apps/provisioning_api/tests/usersTest.php @@ -793,6 +793,7 @@ class Test_Provisioning_Api_Users extends PHPUnit_Framework_TestCase { foreach($this->users as $user) { \OC_User::deleteUser($user); } + OC_Group::deleteGroup('admin'); } }