function field_test_create_stub_entity

7.x field_test.entity.inc field_test_create_stub_entity($id = 1, $vid = 1, $bundle = 'test_bundle', $label = '')

Creates a basic test_entity entity.

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

... See full list

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

File

drupal/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;
}