function EntityFieldQueryTestCase::assertEntityFieldQuery

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.

7 calls to EntityFieldQueryTestCase::assertEntityFieldQuery()
EntityFieldQueryTestCase::testEntityFieldQuery in modules/simpletest/tests/entity_query.test
Tests EntityFieldQuery.
EntityFieldQueryTestCase::testEntityFieldQueryDisablePager in modules/simpletest/tests/entity_query.test
Tests disabling the pager in EntityFieldQuery.
EntityFieldQueryTestCase::testEntityFieldQueryMetaConditions in modules/simpletest/tests/entity_query.test
Tests field meta conditions.
EntityFieldQueryTestCase::testEntityFieldQueryPager in modules/simpletest/tests/entity_query.test
Tests the pager integration of EntityFieldQuery.
EntityFieldQueryTestCase::testEntityFieldQueryRouting in modules/simpletest/tests/entity_query.test
Tests the routing feature of EntityFieldQuery.

... See full list

File

modules/simpletest/tests/entity_query.test, line 1648

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());
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.