You are here

function field_test_create_stub_entity in Drupal 7

Creates a basic test_entity entity.

44 calls to field_test_create_stub_entity()
EntityPropertiesTestCase::testEntityLabel in modules/field/tests/field.test
Tests label key and label callback of an entity.
FieldAttachOtherTestCase::testFieldAttachCache in modules/field/tests/field.test
Test field cache.
FieldAttachOtherTestCase::testFieldAttachForm in modules/field/tests/field.test
Test field_attach_form().
FieldAttachOtherTestCase::testFieldAttachPrepareViewMultiple in modules/field/tests/field.test
Tests the 'multiple entity' behavior of field_attach_prepare_view().
FieldAttachOtherTestCase::testFieldAttachSubmit in modules/field/tests/field.test
Test field_attach_submit().

... See full list

1 string reference to 'field_test_create_stub_entity'
ListDynamicValuesTestCase::setUp in modules/field/modules/list/tests/list.test
Set the default field storage backend for fields created during tests.

File

modules/field/tests/field_test.entity.inc, line 216
Defines an entity type.

Code

function field_test_create_stub_entity($id = 1, $vid = 1, $bundle = 'test_bundle', $label = '') {
  $entity = new stdClass();

  // Only set id and vid properties if they don't come as NULL (creation form).
  if (isset($id)) {
    $entity->ftid = $id;
  }
  if (isset($vid)) {
    $entity->ftvid = $vid;
  }
  $entity->fttype = $bundle;
  $label = !empty($label) ? $label : $bundle . ' label';
  $entity->ftlabel = $label;
  return $entity;
}