|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Specialtactics\L5Api\Tests\Unit; |
| 4 | + |
| 5 | +use App\Http\Controllers\ForumController; |
| 6 | +use Specialtactics\L5Api\Enums\PaginationType; |
| 7 | +use Specialtactics\L5Api\Tests\AppTestCase; |
| 8 | + |
| 9 | +class PaginationTest extends AppTestCase |
| 10 | +{ |
| 11 | + public function testLengthAwarePagination() |
| 12 | + { |
| 13 | + $jsonResponse = $this->actingAsAdmin() |
| 14 | + ->json('GET', '/forums'); |
| 15 | + |
| 16 | + $jsonResponse->assertStatus(200); |
| 17 | + $response = $jsonResponse->decodeResponseJson(); |
| 18 | + |
| 19 | + $this->assertEquals(1, $response['meta']['pagination']['total']); |
| 20 | + $this->assertEquals(1, $response['meta']['pagination']['totalPages']); |
| 21 | + } |
| 22 | + |
| 23 | + public function testSimplePagination() |
| 24 | + { |
| 25 | + $mockForumController = $this->partialMock(ForumController::class); |
| 26 | + $mockForumController->paginationType = PaginationType::SIMPLE; |
| 27 | + |
| 28 | + $jsonResponse = $this->actingAsAdmin() |
| 29 | + ->json('GET', '/forums'); |
| 30 | + |
| 31 | + $jsonResponse->assertStatus(200); |
| 32 | + $response = $jsonResponse->decodeResponseJson(); |
| 33 | + |
| 34 | + // League's Serealiser contract needs to return something, so at the moment it's zero for simple pagination |
| 35 | + $this->assertEquals(0, $response['meta']['pagination']['total']); |
| 36 | + $this->assertEquals(0, $response['meta']['pagination']['totalPages']); |
| 37 | + } |
| 38 | +} |
0 commit comments