summaryrefslogtreecommitdiffstats
path: root/tests/lib/group
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2014-04-08 12:32:30 +0200
committerArthur Schiwon <blizzz@owncloud.com>2014-04-08 12:32:30 +0200
commit9597f4190460c54066586c0eb42ed9a8532ad90a (patch)
treee36eb005181a1be0b6746183909b72ca54d2402c /tests/lib/group
parent5f8d9b3a4e259d1f9c02b482bab37321c0d3b3dc (diff)
downloadnextcloud-server-9597f4190460c54066586c0eb42ed9a8532ad90a.tar.gz
nextcloud-server-9597f4190460c54066586c0eb42ed9a8532ad90a.zip
add group tests
Diffstat (limited to 'tests/lib/group')
-rw-r--r--tests/lib/group/group.php62
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();