]> source.dussan.org Git - nextcloud-server.git/commitdiff
offset needs to be considered in computed limit
authorArthur Schiwon <blizzz@owncloud.com>
Mon, 23 Mar 2015 15:51:40 +0000 (16:51 +0100)
committerArthur Schiwon <blizzz@owncloud.com>
Tue, 24 Mar 2015 09:22:49 +0000 (10:22 +0100)
apps/user_ldap/group_ldap.php
apps/user_ldap/tests/group_ldap.php

index e8d268d3df2848a680303a20449ccbb6bbef2687..cba19f3791c46ffeb11f1991620c59b3546c8abd 100644 (file)
@@ -630,7 +630,7 @@ class GROUP_LDAP extends BackendUtility implements \OCP\GroupInterface {
                }
                $maxGroups = 100000; // limit max results (just for safety reasons)
                if ($limit > -1) {
-                  $overallLimit = min($limit, $maxGroups);
+                  $overallLimit = min($limit + $offset, $maxGroups);
                } else {
                   $overallLimit = $maxGroups;
                }
index d1262e4f5b807e5a8765cae3ca0f1af2651cf573..8066bce02e3787b9147bcf6fd3e859ffc435a094 100644 (file)
@@ -294,4 +294,18 @@ class Test_Group_Ldap extends \PHPUnit_Framework_TestCase {
                $groupBackend->inGroup($uid, $gid);
        }
 
+       public function testGetGroupsWithOffset() {
+               $access = $this->getAccessMock();
+               $this->enableGroups($access);
+
+               $access->expects($this->once())
+                       ->method('ownCloudGroupNames')
+                       ->will($this->returnValue(array('group1', 'group2')));
+
+               $groupBackend = new GroupLDAP($access);
+               $groups = $groupBackend->getGroups('', 2, 2);
+
+               $this->assertSame(2, count($groups));
+       }
+
 }