You are here

public function ResourceServersTest::testGetAll in Auth0 Single Sign On 8.2

Test getting all Resource Servers and looking for the created one.

Return value

void

Throws

\Exception Thrown by the HTTP client when there is a problem with the API call.

File

vendor/auth0/auth0-php/tests/API/Management/ResourceServersTest.php, line 126

Class

ResourceServersTest
Class ResourceServersTest.

Namespace

Auth0\Tests\API\Management

Code

public function testGetAll() {
  $response = self::$api
    ->getAll();
  usleep(AUTH0_PHP_TEST_INTEGRATION_SLEEP);

  // Should have at least the one we created and the management API.
  $this
    ->assertGreaterThanOrEqual(2, count($response));

  // Make sure the one we created was found.
  $found_added = false;
  foreach ($response as $server) {
    if ($server['identifier'] === self::$serverIdentifier) {
      $found_added = true;
      break;
    }
  }
  $this
    ->assertTrue($found_added);

  // Test pagination.
  $response_paged = self::$api
    ->getAll(1, 1);
  usleep(AUTH0_PHP_TEST_INTEGRATION_SLEEP);
  $this
    ->assertNotEmpty($response_paged);
  $this
    ->assertEquals($response[1]['id'], $response_paged[0]['id']);
}