You are here

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

Test a connection create call exceptions.

Return value

void

Throws

\Exception Unsuccessful HTTP call.

File

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

Class

ConnectionsTestMocked
Class ConnectionsTestMocked.

Namespace

Auth0\Tests\API\Management

Code

public function testThatConnectionsCreateThrowsExceptions() {
  $api = new MockManagementApi();
  $caught_no_name_exception = false;
  try {
    $api
      ->call()
      ->connections()
      ->create([
      'strategy' => uniqid(),
    ]);
  } catch (\Exception $e) {
    $caught_no_name_exception = $this
      ->errorHasString($e, 'Missing required "name" field');
  }
  $this
    ->assertTrue($caught_no_name_exception);
  $caught_no_strategy_exception = false;
  try {
    $api
      ->call()
      ->connections()
      ->create([
      'name' => uniqid(),
    ]);
  } catch (\Exception $e) {
    $caught_no_strategy_exception = $this
      ->errorHasString($e, 'Missing required "strategy" field');
  }
  $this
    ->assertTrue($caught_no_strategy_exception);
}