From a0ab7a257858b305434255df2f33ef4b323ac81d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 13 Aug 2015 10:57:08 +0200 Subject: Add all possible links next, prev, first and last --- apps/files_sharing/tests/api/sharees.php | 50 +++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'apps/files_sharing/tests/api') diff --git a/apps/files_sharing/tests/api/sharees.php b/apps/files_sharing/tests/api/sharees.php index ec19036bb8f..7efd29e592d 100644 --- a/apps/files_sharing/tests/api/sharees.php +++ b/apps/files_sharing/tests/api/sharees.php @@ -672,7 +672,7 @@ class ShareesTest extends TestCase { $headers = $ocs->getHeaders(); $this->assertArrayHasKey('Link', $headers); $this->assertStringStartsWith('<', $headers['Link']); - $this->assertStringEndsWith('> rel="next"', $headers['Link']); + $this->assertStringEndsWith('"', $headers['Link']); } } @@ -735,4 +735,52 @@ class ShareesTest extends TestCase { public function testFilterSharees($potentialSharees, $existingSharees, $expectedSharees) { $this->assertEquals($expectedSharees, $this->invokePrivate($this->sharees, 'filterSharees', [$potentialSharees, $existingSharees])); } + + public function dataGetPaginationLinks() { + return [ + [1, 1, ['limit' => 2], []], + [1, 3, ['limit' => 2], [ + '; rel="next"', + '; rel="last"', + ]], + [1, 21, ['limit' => 2], [ + '; rel="next"', + '; rel="last"', + ]], + [2, 21, ['limit' => 2], [ + '; rel="first"', + '; rel="prev"', + '; rel="next"', + '; rel="last"', + ]], + [5, 21, ['limit' => 2], [ + '; rel="first"', + '; rel="prev"', + '; rel="next"', + '; rel="last"', + ]], + [10, 21, ['limit' => 2], [ + '; rel="first"', + '; rel="prev"', + '; rel="next"', + '; rel="last"', + ]], + [11, 21, ['limit' => 2], [ + '; rel="first"', + '; rel="prev"', + ]], + ]; + } + + /** + * @dataProvider dataGetPaginationLinks + * + * @param int $page + * @param int $total + * @param array $params + * @param array $expected + */ + public function testGetPaginationLinks($page, $total, $params, $expected) { + $this->assertEquals($expected, $this->invokePrivate($this->sharees, 'getPaginationLinks', [$page, $total, $params])); + } } -- cgit v1.2.3