convert pagination tests

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2018-04-24 12:04:29 +02:00
parent 0f6d98eed2
commit b069b13226
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
4 changed files with 84 additions and 57 deletions

View File

@ -58,30 +58,12 @@ class IntegrationTestPaging extends AbstractIntegrationTest {
]);
}
/**
* tests that paging works properly against a simple example (reading all
* of few users in small steps)
*
* @return bool
*/
protected function case1() {
$filter = 'objectclass=inetorgperson';
$attributes = ['cn', 'dn'];
$result = $this->access->searchUsers($filter, $attributes);
if(count($result) === 7) {
return true;
}
return false;
}
/**
* fetch first three, afterwards all users
*
* @return bool
*/
protected function case2() {
protected function case1() {
$filter = 'objectclass=inetorgperson';
$attributes = ['cn', 'dn'];
@ -102,23 +84,6 @@ class IntegrationTestPaging extends AbstractIntegrationTest {
return true;
}
/**
* reads all remaining users starting first page
*
* @return bool
*/
protected function case3() {
$filter = 'objectclass=inetorgperson';
$attributes = ['cn', 'dn'];
$result = $this->access->searchUsers($filter, $attributes, null, $this->pagingSize);
if(count($result) === (7 - $this->pagingSize)) {
return true;
}
return false;
}
}
/** @var string $host */

View File

@ -167,4 +167,19 @@ class LDAPContext implements Context {
}
PHPUnit_Framework_Assert::assertTrue(false, 'expected Exception not received');
}
/**
* @Given /^the "([^"]*)" result should contain "([^"]*)" of$/
*/
public function theResultShouldContainOf($type, $expectedCount, TableNode $expectations) {
$listReturnedElements = simplexml_load_string($this->response->getBody())->data[0]->$type[0]->element;
$extractedIDsArray = json_decode(json_encode($listReturnedElements), 1);
$uidsFound = 0;
foreach($expectations->getRows() as $expectation) {
if(in_array($expectation[0], $extractedIDsArray)) {
$uidsFound++;
}
}
PHPUnit_Framework_Assert::assertSame((int)$expectedCount, $uidsFound);
}
}

View File

@ -102,4 +102,3 @@ Feature: LDAP
| ldapHost | foo.bar |
| ldapPort | 2456 |
Then Expect ServerException on failed web login as "alice"

View File

@ -12,3 +12,51 @@ Feature: LDAP
And the "users" result should match
| alice | 1 |
| ghost | 0 |
Scenario: Fetch all users, invoking pagination
Given modify LDAP configuration
| ldapBaseUsers | ou=PagingTest,dc=nextcloud,dc=ci |
| ldapPagingSize | 2 |
And As an "admin"
And sending "GET" to "/cloud/users"
Then the OCS status code should be "200"
And the "users" result should match
| ebba | 1 |
| eindis | 1 |
| fjolnir | 1 |
| gunna | 1 |
| juliana | 1 |
| leo | 1 |
| stigur | 1 |
Scenario: Fetch all users, invoking pagination
Given modify LDAP configuration
| ldapBaseUsers | ou=PagingTest,dc=nextcloud,dc=ci |
| ldapPagingSize | 2 |
And As an "admin"
And sending "GET" to "/cloud/users?limit=10"
Then the OCS status code should be "200"
And the "users" result should match
| ebba | 1 |
| eindis | 1 |
| fjolnir | 1 |
| gunna | 1 |
| juliana | 1 |
| leo | 1 |
| stigur | 1 |
Scenario: Fetch first foall users, invoking pagination
Given modify LDAP configuration
| ldapBaseUsers | ou=PagingTest,dc=nextcloud,dc=ci |
| ldapPagingSize | 2 |
And As an "admin"
And sending "GET" to "/cloud/users?limit=10&offset=2"
Then the OCS status code should be "200"
And the "users" result should contain "5" of
| ebba |
| eindis |
| fjolnir |
| gunna |
| juliana |
| leo |
| stigur |