1 entity_query.test EntityFieldQueryTestCase::assertEntityFieldQuery($query, $intended_results, $message, $ordered = FALSE)

Fetches the results of an EntityFieldQuery and compares.

Parameters

$query: An EntityFieldQuery to run.

$intended_results: A list of results, every entry is again a list, first being the entity type, the second being the entity_id.

$message: The message to be displayed as the result of this test.

$ordered: If FALSE then the result of EntityFieldQuery will match $intended_results even if the order is not the same. If TRUE then order should match too.

File

core/modules/entity/tests/entity_query.test, line 1558
Unit test file for the entity API.

Class

EntityFieldQueryTestCase
Tests EntityFieldQuery.

Code

function assertEntityFieldQuery($query, $intended_results, $message, $ordered = FALSE) {
  $results = array();
  try {
    foreach ($query->execute() as $entity_type => $entity_ids) {
      foreach ($entity_ids as $entity_id => $stub_entity) {
        $results[] = array($entity_type, $entity_id);
      }
    }
    if (!isset($ordered) || !$ordered) {
      sort($results);
      sort($intended_results);
    }
    $this->assertEqual($results, $intended_results, $message);
  }
  catch (Exception $e) {
    $this->fail('Exception thrown: ' . $e->getMessage());
  }
}