You are here

function RelationDummyFieldTestCase::createDummyField in Relation 7

Helper function to create a dummy field with the given widget.

2 calls to RelationDummyFieldTestCase::createDummyField()
RelationDummyFieldTestCase::testDummyFieldDisplayed in relation_dummy_field/tests/relation_dummy_field.test
Create a relation field on the Article node type, and check if it displays the relations correctly on the node page.
RelationDummyFieldTestCase::testDummyFieldXSS in relation_dummy_field/tests/relation_dummy_field.test
Verify that the dummy field protects against XSS attacks.

File

relation_dummy_field/tests/relation_dummy_field.test, line 28
Tests for Relation Dummy Field module.

Class

RelationDummyFieldTestCase
Functional test of Relation's integration with the Dummy Field.

Code

function createDummyField($widget_type = 'relation_default') {
  $field_name = drupal_strtolower($this
    ->randomName()) . '_field_name';
  $field = array(
    'field_name' => $field_name,
    'type' => 'relation',
    'entity_types' => array(
      'node',
    ),
  );
  field_create_field($field);
  $instance = array(
    'field_name' => $field_name,
    'entity_type' => 'node',
    'bundle' => 'article',
    'label' => $this
      ->randomString(),
    'widget_type' => $widget_type,
    'display' => array(
      'default' => array(
        'label' => 'hidden',
        'type' => $widget_type,
      ),
      'teaser' => array(
        'label' => 'hidden',
        'type' => 'hidden',
      ),
    ),
  );
  field_create_instance($instance);
  return $field_name;
}