protected function PastDBTest::addField

7-1 past_db.test protected PastDBTest::addField($bundle)

Creates an entityreference field and adds an instance of it to a bundle.

Parameters

string $bundle: The bundle name.

Return value

array The definition of the field instance.

1 call to PastDBTest::addField()
PastDBTest::testFieldability in modules/past_db/past_db.test
Test fieldability.

File

modules/past_db/past_db.test, line 312
Contains tests for the past_db Admin UI.

Class

PastDBTest
Tests Past DB.

Code

protected function addField($bundle) {
  $field_info = array(
    'entity_types' => array('past_event'),
    'settings' => array(
      'target_type' => 'past_event',
    ),
    'field_name' => 'field_fieldtest',
    'type' => 'entityreference',
    'module' => 'entityreference',
    'bundles' => array(
      'past_event' => array(
        0 => $bundle,
      ),
    ),
  );
  field_create_field($field_info);
  $instance_info = array(
    'label' => 'test entity reference',
    'display' => array(
      'default' => array(
        'label' => 'above',
        'type' => 'entityreference_label',
        'settings' => array(
          'link' => FALSE,
        ),
      ),
    ),
    'field_name' => 'field_fieldtest',
    'entity_type' => 'past_event',
    'bundle' => $bundle,
  );
  field_create_instance($instance_info);
  return $instance_info;
}