function GenericFieldTest::formTestGenericFieldNodeAddDeleteForm

Add and delete all field types through Form API.

@access public

1 call to GenericFieldTest::formTestGenericFieldNodeAddDeleteForm()
FieldTestPermissionsExample::testAddRemoveFieldnoteForm in field_permission_example/tests/field_permission_example.test
Add and remove the field through Form API.

File

field_permission_example/tests/field_permission_example.test, line 204

Class

GenericFieldTest
A generic field testing class.

Code

public function formTestGenericFieldNodeAddDeleteForm() {
  // Create and login user.
  $account = $this->drupalCreateUser(array(
    'administer content types',
    'administer fields',
  ));
  $this->drupalLogin($account);
  // Add a content type.
  $node_type = $this->drupalCreateContentType();
  // Add all our testable fields.
  $field_names = $this->formAddAllFields($node_type);
  // Now let's delete all the fields.
  foreach ($field_names as $field_name) {
    // This is the path for the 'delete' link on field admin page.
    $this->drupalGet('admin/structure/types/manage/' . $node_type->name . '/fields/field_' . $field_name . '/delete');
    // Click the 'delete' button.
    $this->drupalPost(NULL, array(), t('Delete'));
    $this->assertText(t('The field @field has been deleted from the @type content type.', array(
      '@field' => $field_name,
      '@type' => $node_type->name,
    )));
  }
}