You are here

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

Test a create user call.

Return value

void

Throws

\Exception Should not be thrown in this test.

File

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

Class

UsersMockedTest
Class UsersMockedTest.

Namespace

Auth0\Tests\API\Management

Code

public function testThatCreateUserRequestIsFormattedProperly() {
  $api = new MockManagementApi([
    new Response(200, self::$headers),
  ]);
  $api
    ->call()
    ->users()
    ->create([
    'connection' => '__test_connection__',
    'email' => '__test_email__',
    'password' => '__test_password__',
  ]);
  $this
    ->assertEquals('POST', $api
    ->getHistoryMethod());
  $this
    ->assertEquals('https://api.test.local/api/v2/users', $api
    ->getHistoryUrl());
  $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]);
  $body = $api
    ->getHistoryBody();
  $this
    ->assertArrayHasKey('connection', $body);
  $this
    ->assertEquals('__test_connection__', $body['connection']);
  $this
    ->assertArrayHasKey('email', $body);
  $this
    ->assertEquals('__test_email__', $body['email']);
  $this
    ->assertArrayHasKey('password', $body);
  $this
    ->assertEquals('__test_password__', $body['password']);
}