Skip to content

Commit

Permalink
Add pagination test.
Browse files Browse the repository at this point in the history
  • Loading branch information
neomerx committed Aug 28, 2017
1 parent 18ca83f commit 9cfe5a3
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tests/CommentApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use App\Data\Models\Comment;
use App\Json\Schemes\CommentScheme;
use Limoncello\Flute\Adapters\PaginationStrategy;
use Limoncello\Testing\JsonApiCallsTrait;

/**
Expand Down Expand Up @@ -73,13 +74,30 @@ public function testIndexWithAuthorFilter()
$this->assertCount(2, $resources->data);
}

/**
* Test index with parameters.
*/
public function testIndexWithTooManyItems()
{
$queryParams = [
'page' => [
'size' => '10000',
],
];
$response = $this->get(self::API_URI, $queryParams);

$this->assertEquals(200, $response->getStatusCode());
$this->assertNotNull($resources = json_decode((string)$response->getBody()));
$this->assertCount(PaginationStrategy::MAX_LIMIT_SIZE, $resources->data);
}

/**
* Test Comment's API.
*/
public function testRead()
{
$commentId = '1';
$response = $this->get(self::API_URI . "/$commentId");
$commentId = '1';
$response = $this->get(self::API_URI . "/$commentId");
$this->assertEquals(200, $response->getStatusCode());

$json = json_decode((string)$response->getBody());
Expand Down

0 comments on commit 9cfe5a3

Please sign in to comment.