You are here

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

Test an update 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 85

Class

UsersMockedTest
Class UsersMockedTest.

Namespace

Auth0\Tests\API\Management

Code

public function testThatUpdateUserRequestIsFormattedProperly() {
  $api = new MockManagementApi([
    new Response(200, self::$headers),
  ]);
  $api
    ->call()
    ->users()
    ->update('__test_user_id__', [
    'given_name' => '__test_given_name__',
    'user_metadata' => [
      '__test_meta_key__' => '__test_meta_value__',
    ],
  ]);
  $this
    ->assertEquals('PATCH', $api
    ->getHistoryMethod());
  $this
    ->assertEquals('https://api.test.local/api/v2/users/__test_user_id__', $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('given_name', $body);
  $this
    ->assertEquals('__test_given_name__', $body['given_name']);
  $this
    ->assertArrayHasKey('user_metadata', $body);
  $this
    ->assertArrayHasKey('__test_meta_key__', $body['user_metadata']);
  $this
    ->assertEquals('__test_meta_value__', $body['user_metadata']['__test_meta_key__']);
}