You are here

protected function CommentAlterBaseTestCase::createField in Comment Alter 7

Creates a field and field instance on the $this->content_type type.

@parem string $widget_type The widget name (ie. options_select).

Parameters

string $field_type: The field type name (ie. list_text).

array $field_settings: An array that gets added to the array passed to field_create_field().

array $instance_settings: An array that gets added to the array passed to field_create_instance().

boolean $comment_alter: Whether to enable comment_alter for this field instance right away.

Return value

string The name of the field that was created.

See also

field_create_field()

field_create_instance()

13 calls to CommentAlterBaseTestCase::createField()
CommentAlterAdminTestCase::testCommentManageFields in ./comment_alter.test
CommentAlterAdminTestCase::testNodeFieldInstanceSettings in ./comment_alter.test
CommentAlterAdminTestCase::testStatusReport in ./comment_alter.test
CommentAlterDeletedRevisionTestCase::testOptionsSelectSingle in ./comment_alter.test
CommentAlterFileTestCase::testFileFieldMultiple in ./comment_alter.test

... See full list

File

./comment_alter.test, line 61
Functional tests for the Comment Alter module.

Class

CommentAlterBaseTestCase
Parent of all the test cases for Comment Alter.

Code

protected function createField($field_type, $widget_type, $field_settings = array(), $instance_settings = array(), $comment_alter = TRUE) {
  $field_name = drupal_strtolower($this
    ->randomName() . '_field_name');
  field_create_field(array(
    'field_name' => $field_name,
    'type' => $field_type,
  ) + $field_settings);
  field_create_instance(array(
    'field_name' => $field_name,
    'entity_type' => 'node',
    'widget' => array(
      'type' => $widget_type,
    ),
    'bundle' => $this->content_type,
    'settings' => $instance_settings,
    'comment_alter' => $comment_alter,
  ));
  return $field_name;
}