You are here

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

Test a basic update request.

Return value

void

Throws

\Exception Unsuccessful HTTP call.

File

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

Class

ConnectionsTestMocked
Class ConnectionsTestMocked.

Namespace

Auth0\Tests\API\Management

Code

public function testConnectionsUpdate() {
  $api = new MockManagementApi([
    new Response(200, self::$headers),
  ]);
  $id = 'con_testConnection10';
  $update_data = [
    'metadata' => [
      'meta1' => 'value1',
    ],
  ];
  $api
    ->call()
    ->connections()
    ->update($id, $update_data);
  $request_body = $api
    ->getHistoryBody();
  $this
    ->assertEquals($update_data, $request_body);
  $this
    ->assertEquals('PATCH', $api
    ->getHistoryMethod());
  $this
    ->assertEquals('https://api.test.local/api/v2/connections/' . $id, $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]);
}