You are here

public function CommentAlterAdminTestCase::testCommentManageFields in Comment Alter 7

File

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

Class

CommentAlterAdminTestCase
Functional tests for the admin UIs provided by Comment Alter.

Code

public function testCommentManageFields() {

  // Attach to the node with Comment Alter.
  $field_name = $this
    ->createField('text', 'text_textfield', array(
    'cardinality' => 1,
  ));
  $type_name = str_replace('_', '-', $this->content_type);
  $manage_fields_path = "admin/structure/types/manage/{$type_name}/comment/fields";

  // So, if we go to the Comment bundles 'Manage Fields' page, we shouldn't
  // see the the field as an option to add.
  $this
    ->drupalGet($manage_fields_path);
  $this
    ->assertFalse($this
    ->hasExistingFieldOption($field_name));

  // Then if we remove it from comment alter, it should become an option.
  $instance_info = field_info_instance('node', $field_name, $this->content_type);
  $instance_info['comment_alter'] = FALSE;
  field_update_instance($instance_info);
  $this
    ->drupalGet($manage_fields_path);
  $this
    ->assertTrue($this
    ->hasExistingFieldOption($field_name));
}