You are here

public function RolesTestMocked::testThatGetUsersRequestIsFormattedProperly in Auth0 Single Sign On 8.2

Test a paginated get role users call.

Return value

void

Throws

\Exception Should not be thrown in this test.

File

vendor/auth0/auth0-php/tests/API/Management/RolesMockedTest.php, line 539

Class

RolesTestMocked
Class RolesTestMocked.

Namespace

Auth0\Tests\API\Management

Code

public function testThatGetUsersRequestIsFormattedProperly() {
  $api = new MockManagementApi([
    new Response(200, self::$headers),
  ]);
  $api
    ->call()
    ->roles()
    ->getUsers('__test_role_id__', [
    'per_page' => 6,
    'include_totals' => 1,
  ]);
  $this
    ->assertEquals('GET', $api
    ->getHistoryMethod());
  $this
    ->assertStringStartsWith('https://api.test.local/api/v2/roles/__test_role_id__/users', $api
    ->getHistoryUrl());
  $headers = $api
    ->getHistoryHeaders();
  $this
    ->assertEquals('Bearer __api_token__', $headers['Authorization'][0]);
  $this
    ->assertEquals(self::$expectedTelemetry, $headers['Auth0-Client'][0]);
  $query = $api
    ->getHistoryQuery();
  $this
    ->assertContains('page=6', $query);
  $this
    ->assertContains('include_totals=true', $query);
}