You are here

public function BasicCrudTest::testAll in Auth0 Single Sign On 8.2

All basic CRUD test assertions.

Return value

void

File

vendor/auth0/auth0-php/tests/API/BasicCrudTest.php, line 140

Class

BasicCrudTest
Class BasicCrudTest.

Namespace

Auth0\Tests\API

Code

public function testAll() {

  // Test a generic "create entity" method for this API client.
  $created_entity = $this->api
    ->create($this
    ->getCreateBody());
  $this
    ->afterCreate($created_entity);
  $created_entity_id = $this
    ->getId($created_entity);

  // Test a generic "get entity" method.
  $got_entity = $this->api
    ->get($created_entity_id);

  // Make sure what we got matches what we created.
  $this
    ->afterCreate($got_entity);

  // Test a generic "get all entities" method for this API client.
  $all_entities = $this
    ->getAllEntities($created_entity);

  // Look through our returned results for the created item, if indicated.
  if ($this->findCreatedItem && !empty($all_entities)) {
    $found = false;
    foreach ($all_entities as $value) {
      if ($this
        ->getId($value) === $created_entity_id) {
        $found = true;
        break;
      }
    }
    $this
      ->assertTrue($found, 'Created item not found');
  }

  // Test a generic "update entity" method for this API client.
  $updated_entity = $this->api
    ->update($created_entity_id, $this
    ->getUpdateBody());
  $this
    ->afterUpdate($updated_entity);

  // Test a generic "delete entity" method for this API client.
  $this->api
    ->delete($created_entity_id);
}