You are here

function field_test_entity_test_load in SimpleTest 7

File

tests/field_test.module, line 195

Code

function field_test_entity_test_load($ftid, $ftvid = NULL) {

  // Load basic strucure.
  $query = db_select('test_entity', 'fte', array())
    ->fields('fte')
    ->condition('ftid', $ftid);
  if ($ftvid) {
    $query
      ->condition('ftvid', $ftvid);
  }
  $entities = $query
    ->execute()
    ->fetchAllAssoc('ftid');

  // Attach fields.
  if ($ftvid) {
    field_attach_load_revision('test_entity', $entities);
  }
  else {
    field_attach_load('test_entity', $entities);
  }
  return $entities[$ftid];
}