You are here

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

Test a get call with included fields.

Return value

void

Throws

\Exception Unsuccessful HTTP call.

File

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

Class

ConnectionsTestMocked
Class ConnectionsTestMocked.

Namespace

Auth0\Tests\API\Management

Code

public function testThatConnectionsGetIncludesFields() {
  $api = new MockManagementApi([
    new Response(200, self::$headers),
    new Response(200, self::$headers),
  ]);
  $id = 'con_testConnection10';
  $fields = [
    'name',
    'strategy',
  ];
  $api
    ->call()
    ->connections()
    ->get($id, $fields);
  $this
    ->assertEquals('GET', $api
    ->getHistoryMethod());
  $this
    ->assertStringStartsWith('https://api.test.local/api/v2/connections/' . $id, $api
    ->getHistoryUrl());
  $this
    ->assertContains('fields=' . implode(',', $fields), $api
    ->getHistoryQuery());
  $this
    ->assertNotContains('include_fields=', $api
    ->getHistoryQuery());

  // Test an explicit true for includeFields.
  $include_fields = true;
  $api
    ->call()
    ->connections()
    ->get($id, $fields, $include_fields);
  $this
    ->assertContains('include_fields=true', $api
    ->getHistoryQuery());
}