You are here

public function UsersMockedTest::testThatGetLogsRequestIsFormattedProperly in Auth0 Single Sign On 8.2

Test that a get logs call is formatted properly.

Return value

void

Throws

\Exception Should not be thrown in this test.

File

vendor/auth0/auth0-php/tests/API/Management/UsersMockedTest.php, line 1019

Class

UsersMockedTest
Class UsersMockedTest.

Namespace

Auth0\Tests\API\Management

Code

public function testThatGetLogsRequestIsFormattedProperly() {
  $api = new MockManagementApi([
    new Response(200, self::$headers),
  ]);
  $api
    ->call()
    ->users()
    ->getLogs('__test_user_id__', [
    'per_page' => 3,
    'page' => 2,
    'include_totals' => 0,
    'fields' => 'date,type,ip',
  ]);
  $this
    ->assertEquals('GET', $api
    ->getHistoryMethod());
  $this
    ->assertStringStartsWith('https://api.test.local/api/v2/users/__test_user_id__/logs?', $api
    ->getHistoryUrl());
  $query = $api
    ->getHistoryQuery();
  $this
    ->assertContains('per_page=3', $query);
  $this
    ->assertContains('page=2', $query);
  $this
    ->assertContains('include_totals=false', $query);
  $this
    ->assertContains('fields=date,type,ip', $query);
  $headers = $api
    ->getHistoryHeaders();
  $this
    ->assertEquals('Bearer __api_token__', $headers['Authorization'][0]);
  $this
    ->assertEquals(self::$expectedTelemetry, $headers['Auth0-Client'][0]);
}