1 field_permission_example.test | public GenericFieldTest::formTestGenericFieldNodeAddDeleteForm() |
Add and delete all field types through Form API.
@access public
File
- modules/
examples/ field_permission_example/ tests/ field_permission_example.test, line 193 - Tests for Field Permission Example.
Class
- GenericFieldTest
- A generic field testing class.
Code
public function formTestGenericFieldNodeAddDeleteForm() {
// Create and login user.
$account = $this->backdropCreateUser(array(
'administer content types',
'administer fields',
));
$this->backdropLogin($account);
// Add a content type.
$node_type = $this->backdropCreateContentType();
// 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->backdropGet('admin/structure/types/manage/' .
$node_type->name . '/fields/field_' . $field_name . '/delete');
// Click the 'delete' button.
$this->backdropPost(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)));
}
}