You are here

public function GrantsTestMocked::testThatGrantsGetAllPaginates in Auth0 Single Sign On 8.2

Test that getAll sends pagination parameters with the request.

Return value

void

Throws

\Exception Unsuccessful HTTP call.

File

vendor/auth0/auth0-php/tests/API/Management/GrantsMockedTest.php, line 77

Class

GrantsTestMocked
Class GrantsTestMocked.

Namespace

Auth0\Tests\API\Management

Code

public function testThatGrantsGetAllPaginates() {
  $api = new MockManagementApi([
    new Response(200),
    new Response(200),
    new Response(200),
  ]);
  $page = 1;
  $per_page = 5;
  $api
    ->call()
    ->grants()
    ->getAll($page, $per_page);
  $this
    ->assertEquals('GET', $api
    ->getHistoryMethod());
  $this
    ->assertStringStartsWith('https://api.test.local/api/v2/grants', $api
    ->getHistoryUrl());
  $this
    ->assertContains('page=1', $api
    ->getHistoryQuery());
  $this
    ->assertContains('per_page=5', $api
    ->getHistoryQuery());
  $page = 2;
  $per_page = null;
  $api
    ->call()
    ->grants()
    ->getAll($page, $per_page);
  $this
    ->assertContains('page=2', $api
    ->getHistoryQuery());
  $this
    ->assertNotContains('per_page=', $api
    ->getHistoryQuery());
  $page = false;
  $per_page = false;
  $api
    ->call()
    ->grants()
    ->getAll($page, $per_page);
  $this
    ->assertNull($api
    ->getHistoryQuery());
}