diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2014-04-14 20:45:12 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2014-04-14 20:45:12 +0200 |
commit | 340089f270a778aeb296b1744821dcdb5878131e (patch) | |
tree | f579bd25e61fd165142e8f95383ce73423c1494f /tests | |
parent | 9046f7b2f81d6f20c2d61ebd6b408945118928b7 (diff) | |
parent | 240732162509d0caf71ef5f1414b2595bbe47fe9 (diff) | |
download | nextcloud-server-340089f270a778aeb296b1744821dcdb5878131e.tar.gz nextcloud-server-340089f270a778aeb296b1744821dcdb5878131e.zip |
Merge pull request #8059 from owncloud/countUsersInGroup
add optional countUsersInGroup method to group backends
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/group/group.php | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/lib/group/group.php b/tests/lib/group/group.php index 3982c00e45f..147532f9947 100644 --- a/tests/lib/group/group.php +++ b/tests/lib/group/group.php @@ -299,6 +299,68 @@ class Group extends \PHPUnit_Framework_TestCase { $this->assertEquals('user1', $user1->getUID()); } + public function testCountUsers() { + $backend1 = $this->getMock('OC_Group_Database'); + $userManager = $this->getUserManager(); + $group = new \OC\Group\Group('group1', array($backend1), $userManager); + + $backend1->expects($this->once()) + ->method('countUsersInGroup') + ->with('group1', '2') + ->will($this->returnValue(3)); + + $backend1->expects($this->any()) + ->method('implementsActions') + ->will($this->returnValue(true)); + + $users = $group->count('2'); + + $this->assertSame(3, $users); + } + + public function testCountUsersMultipleBackends() { + $backend1 = $this->getMock('OC_Group_Database'); + $backend2 = $this->getMock('OC_Group_Database'); + $userManager = $this->getUserManager(); + $group = new \OC\Group\Group('group1', array($backend1, $backend2), $userManager); + + $backend1->expects($this->once()) + ->method('countUsersInGroup') + ->with('group1', '2') + ->will($this->returnValue(3)); + $backend1->expects($this->any()) + ->method('implementsActions') + ->will($this->returnValue(true)); + + $backend2->expects($this->once()) + ->method('countUsersInGroup') + ->with('group1', '2') + ->will($this->returnValue(4)); + $backend2->expects($this->any()) + ->method('implementsActions') + ->will($this->returnValue(true)); + + $users = $group->count('2'); + + $this->assertSame(7, $users); + } + + public function testCountUsersNoMethod() { + $backend1 = $this->getMock('OC_Group_Database'); + $userManager = $this->getUserManager(); + $group = new \OC\Group\Group('group1', array($backend1), $userManager); + + $backend1->expects($this->never()) + ->method('countUsersInGroup'); + $backend1->expects($this->any()) + ->method('implementsActions') + ->will($this->returnValue(false)); + + $users = $group->count('2'); + + $this->assertSame(false, $users); + } + public function testDelete() { $backend = $this->getMock('OC_Group_Database'); $userManager = $this->getUserManager(); |