You are here

public function NodeReferenceFormTest::setUp in References 7.2

Setup.

Overrides FieldTestCase::setUp

File

node_reference/node_reference.test, line 27
Initial node_reference tests.

Class

NodeReferenceFormTest
Unit tests for referenceability of node types in entity forms.

Code

public function setUp() {
  parent::setUp(array(
    'node_reference',
    'field_test',
  ));
  $this->langcode = LANGUAGE_NONE;
  $this->field_name = 'test_node_reference';
  $this->field = array(
    'field_name' => $this->field_name,
    'type' => 'node_reference',
    'cardinality' => 1,
    'settings' => array(
      'referenceable_types' => array_keys(node_type_get_names()),
    ),
  );
  $this->field = field_create_field($this->field);
  $this->instance = array(
    'field_name' => $this->field_name,
    'entity_type' => 'test_entity',
    'bundle' => 'test_bundle',
    'widget' => array(
      'type' => 'options_buttons',
    ),
  );
  $this->instance = field_create_instance($this->instance);
  $this->nodes = array();
  foreach (node_type_get_names() as $type_name => $type_title) {
    $this->nodes[$type_name] = $this
      ->drupalCreateNode(array(
      'type' => $type_name,
      'title' => $this
        ->randomName(8),
    ));
    $this
      ->pass(t('Created %type node %nid: %title', array(
      '%type' => $type_name,
      '%nid' => $this->nodes[$type_name]->nid,
      '%title' => $this->nodes[$type_name]->title,
    )), 'destination creation');
  }
}