You are here

public function ConnectionsTestMocked::testConnectionsCreate in Auth0 Single Sign On 8.2

Test a basic connection create call.

Return value

void

Throws

\Exception Unsuccessful HTTP call.

File

vendor/auth0/auth0-php/tests/API/Management/ConnectionsMockedTest.php, line 314

Class

ConnectionsTestMocked
Class ConnectionsTestMocked.

Namespace

Auth0\Tests\API\Management

Code

public function testConnectionsCreate() {
  $api = new MockManagementApi([
    new Response(200, self::$headers),
  ]);
  $name = 'TestConnection01';
  $strategy = 'test-strategy-01';
  $api
    ->call()
    ->connections()
    ->create([
    'name' => $name,
    'strategy' => $strategy,
  ]);
  $request_body = $api
    ->getHistoryBody();
  $this
    ->assertEquals($name, $request_body['name']);
  $this
    ->assertEquals($strategy, $request_body['strategy']);
  $this
    ->assertEquals('POST', $api
    ->getHistoryMethod());
  $this
    ->assertEquals('https://api.test.local/api/v2/connections', $api
    ->getHistoryUrl());
  $this
    ->assertEmpty($api
    ->getHistoryQuery());
  $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]);
}