1 field_permission_example.test | protected GenericFieldTest::formCreateField($manage_path, $field_type, $field_name, $widget_type, $cardinality) |
Create a field using the content type management form.
Parameters
mixed $manage_path: Path to our content type management form.
mixed $field_type: The type of field we're adding.
mixed $field_name: The name of the field instance we want.
mixed $widget_type: Which widget would we like?
mixed $cardinality: Cardinality for this field instance.
File
- modules/
examples/ field_permission_example/ tests/ field_permission_example.test, line 281 - Tests for Field Permission Example.
Class
- GenericFieldTest
- A generic field testing class.
Code
protected function formCreateField($manage_path, $field_type, $field_name, $widget_type, $cardinality) {
// $manage_path is the field edit form for our content type.
$this->backdropGet($manage_path);
$edit = array(
'fields[_add_new_field][label]' => $field_name,
'fields[_add_new_field][field_name]' => $field_name,
'fields[_add_new_field][type]' => $field_type,
'fields[_add_new_field][widget_type]' => $widget_type,
);
$this->backdropPost(NULL, $edit, t('Save'));
// Assume there are no settings for this,
// so just press the button.
$this->backdropPost(NULL, array(), t('Save settings'));
debug(
t('Saved settings for field !field_name with widget !widget_type and cardinality !cardinality',
array(
'!field_name' => $field_name,
'!widget_type' => $widget_type,
'!cardinality' => $cardinality,
)
)
);
$this->assertText(t('Saved @name configuration.', array('@name' => $field_name)));
}