function GenericFieldTest::codeTestGenericRemoveAllFields
Remove all fields in $this->field_names.
Parameters
mixed $node_type: A content type object. If none is specified, the test fails.
1 call to GenericFieldTest::codeTestGenericRemoveAllFields()
- FieldTestPermissionsExample::testAddRemoveFieldnoteCode in field_permission_example/
tests/ field_permission_example.test - Add and remove the field through code.
File
-
field_permission_example/
tests/ field_permission_example.test, line 181
Class
- GenericFieldTest
- A generic field testing class.
Code
public function codeTestGenericRemoveAllFields($node_type = NULL) {
if (!$node_type) {
$this->fail('No node type.');
}
if (count($this->instanceNames) < 1) {
$this->fail('There are no instances to remove.');
return;
}
foreach ($this->instanceNames as $instance_name) {
$instance = field_info_instance('node', $instance_name, $node_type->name);
$this->assertTrue($instance, "Instance exists, now we'll delete it.");
field_delete_field($instance_name);
$instance = field_info_instance('node', $instance_name, $node_type->name);
$this->assertFalse($instance, 'Instance was deleted.');
}
$this->instanceNames = array();
}