You are here

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

Test create role is requested properly.

Return value

void

Throws

\Exception Should not be thrown in this test.

File

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

Class

RolesTestMocked
Class RolesTestMocked.

Namespace

Auth0\Tests\API\Management

Code

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