You are here

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

Test a link account call.

Return value

void

Throws

\Exception Should not be thrown in this test.

File

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

Class

UsersMockedTest
Class UsersMockedTest.

Namespace

Auth0\Tests\API\Management

Code

public function testThatLinkAccountRequestIsFormattedProperly() {
  $api = new MockManagementApi([
    new Response(200, self::$headers),
  ]);
  $api
    ->call()
    ->users()
    ->linkAccount('__test_user_id__', [
    'provider' => '__test_provider__',
    'connection_id' => '__test_connection_id__',
    'user_id' => '__test_secondary_user_id__',
  ]);
  $this
    ->assertEquals('POST', $api
    ->getHistoryMethod());
  $this
    ->assertEquals('https://api.test.local/api/v2/users/__test_user_id__/identities', $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('provider', $body);
  $this
    ->assertEquals('__test_provider__', $body['provider']);
  $this
    ->assertArrayHasKey('connection_id', $body);
  $this
    ->assertEquals('__test_connection_id__', $body['connection_id']);
  $this
    ->assertArrayHasKey('user_id', $body);
  $this
    ->assertEquals('__test_secondary_user_id__', $body['user_id']);
}