You are here

public function ClientsTest::testThatCreateRequestIsFormedProperly in Auth0 Single Sign On 8.2

Throws

\Exception

File

vendor/auth0/auth0-php/tests/API/Management/ClientsTest.php, line 150

Class

ClientsTest
Class ClientsTest

Namespace

Auth0\Tests\API\Management

Code

public function testThatCreateRequestIsFormedProperly() {
  $api = new MockManagementApi([
    new Response(200, self::$headers),
  ]);
  $api
    ->call()
    ->clients()
    ->create([
    'name' => '__test_name__',
    'app_type' => '__test_app_type__',
  ]);
  $this
    ->assertEquals('POST', $api
    ->getHistoryMethod());
  $this
    ->assertEquals('https://api.test.local/api/v2/clients', $api
    ->getHistoryUrl());
  $body = $api
    ->getHistoryBody();
  $this
    ->assertArrayHasKey('name', $body);
  $this
    ->assertEquals('__test_name__', $body['name']);
  $this
    ->assertArrayHasKey('app_type', $body);
  $this
    ->assertEquals('__test_app_type__', $body['app_type']);
  $headers = $api
    ->getHistoryHeaders();
  $this
    ->assertEquals('Bearer __api_token__', $headers['Authorization'][0]);
  $this
    ->assertEquals(self::$expectedTelemetry, $headers['Auth0-Client'][0]);
  $this
    ->assertEquals('application/json', $headers['Content-Type'][0]);
}