diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2015-11-05 11:50:57 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2015-11-05 11:50:57 +0100 |
commit | 51ead4e59bc3695a2279758b0b410f3e2b5478e7 (patch) | |
tree | e36847b68a704b5cd8c53f9ce97cbf0f2ac58be6 /tests | |
parent | 6e7461f64caf8211f554e7e723d25a1b99b80bf8 (diff) | |
download | nextcloud-server-51ead4e59bc3695a2279758b0b410f3e2b5478e7.tar.gz nextcloud-server-51ead4e59bc3695a2279758b0b410f3e2b5478e7.zip |
subadmin methods should not return any null user or group
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/subadmin.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/lib/subadmin.php b/tests/lib/subadmin.php index 0855e514c7e..960943c22f5 100644 --- a/tests/lib/subadmin.php +++ b/tests/lib/subadmin.php @@ -55,6 +55,28 @@ class SubAdmin extends \Test\TestCase { if (!$this->groupManager->groupExists('admin')) { $this->groupManager->createGroup('admin'); } + + // Create "orphaned" users and groups (scenario: temporarily disabled + // backend) + $qb = $this->dbConn->getQueryBuilder(); + $qb->insert('group_admin') + ->values([ + 'gid' => $qb->createNamedParameter($this->groups[0]->getGID()), + 'uid' => $qb->createNamedParameter('orphanedUser') + ]) + ->execute(); + $qb->insert('group_admin') + ->values([ + 'gid' => $qb->createNamedParameter('orphanedGroup'), + 'uid' => $qb->createNamedParameter('orphanedUser') + ]) + ->execute(); + $qb->insert('group_admin') + ->values([ + 'gid' => $qb->createNamedParameter('orphanedGroup'), + 'uid' => $qb->createNamedParameter($this->users[0]->getUID()) + ]) + ->execute(); } public function tearDown() { @@ -65,6 +87,12 @@ class SubAdmin extends \Test\TestCase { foreach($this->groups as $group) { $group->delete(); } + + $qb = $this->dbConn->getQueryBuilder(); + $qb->delete('group_admin') + ->where($qb->expr()->eq('uid', $qb->createNamedParameter('orphanedUser'))) + ->orWhere($qb->expr()->eq('gid', $qb->createNamedParameter('orphanedGroup'))) + ->execute(); } public function testCreateSubAdmin() { @@ -118,6 +146,7 @@ class SubAdmin extends \Test\TestCase { $this->assertContains($this->groups[0], $result); $this->assertContains($this->groups[1], $result); $this->assertNotContains($this->groups[2], $result); + $this->assertNotContains(null, $result); $this->assertTrue($subAdmin->deleteSubAdmin($this->users[0], $this->groups[0])); $this->assertTrue($subAdmin->deleteSubAdmin($this->users[0], $this->groups[1])); @@ -133,6 +162,7 @@ class SubAdmin extends \Test\TestCase { $this->assertContains($this->users[0], $result); $this->assertContains($this->users[1], $result); $this->assertNotContains($this->users[2], $result); + $this->assertNotContains(null, $result); $this->assertTrue($subAdmin->deleteSubAdmin($this->users[0], $this->groups[0])); $this->assertTrue($subAdmin->deleteSubAdmin($this->users[1], $this->groups[0])); @@ -150,6 +180,7 @@ class SubAdmin extends \Test\TestCase { $this->assertContains(['user' => $this->users[0], 'group' => $this->groups[0]], $result); $this->assertContains(['user' => $this->users[1], 'group' => $this->groups[1]], $result); $this->assertContains(['user' => $this->users[2], 'group' => $this->groups[1]], $result); + $this->assertNotContains(['user' => null, 'group' => null], $result); } public function testIsSubAdminofGroup() { |