You are here

protected function JsonApiDefaultsFunctionalTest::assertPagerLink in JSON:API Extras 8.3

Asserts a pager link with a given url.

Parameters

string $url: The url of the checked pager link.

int $page: The page number the link is pointing to.

int $page_limit: Limit for amount of items displayed per page.

1 call to JsonApiDefaultsFunctionalTest::assertPagerLink()
JsonApiDefaultsFunctionalTest::assertPagination in modules/jsonapi_defaults/tests/src/Functional/JsonApiDefaultsFunctionalTest.php
Checks if pagination links on a jsonapi response are working as expected.

File

modules/jsonapi_defaults/tests/src/Functional/JsonApiDefaultsFunctionalTest.php, line 202

Class

JsonApiDefaultsFunctionalTest
The test class for the JSON API Defaults functionality.

Namespace

Drupal\Tests\jsonapi_defaults\Functional

Code

protected function assertPagerLink($url, $page, $page_limit) {
  $query = parse_url($url, PHP_URL_QUERY);
  $query_params = parse_query($query);
  $this
    ->assertArrayHasKey('page[limit]', $query_params);
  $this
    ->assertArrayHasKey('page[offset]', $query_params);
  $this
    ->assertEquals($query_params['page[offset]'], $page * $page_limit);
  $this
    ->assertEquals($query_params['page[limit]'], $page_limit);
}