protected function ColodFieldPlainTextTest::create_field in Color Field 7
Same name and namespace in other branches
- 7.2 color_field.test \ColodFieldPlainTextTest::create_field()
Utility function to create fields on a content type.
Parameters
$field_name: Name of the field, like field_something
$widget_type: Widget type, like field_example_3text
$cardinality: Cardinality
1 call to ColodFieldPlainTextTest::create_field()
- ColodFieldPlainTextTest::testColorFieldDefault in ./
color_field.test - Test basic functionality of the color field.
File
- ./
color_field.test, line 130 - Tests for Color Field.
Class
- ColodFieldPlainTextTest
- Defines a class for testing color field module (Plain Text).
Code
protected function create_field($field_name, $details) {
$edit = array(
'fields[_add_new_field][label]' => $details['label'],
'fields[_add_new_field][field_name]' => $field_name,
'fields[_add_new_field][type]' => 'color_field_rgb',
'fields[_add_new_field][widget_type]' => $details['widget_type'],
);
$this
->drupalPost(NULL, $edit, t('Save'));
// There are no settings for this, so just press the button.
$this
->drupalPost(NULL, array(), t('Save field settings'));
$edit = array(
'field[cardinality]' => (string) $details['cardinality'],
);
// Using all the default settings, so press the button.
$this
->drupalPost(NULL, $edit, 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' => $details['widget_type'],
'%cardinality' => $details['cardinality'],
)));
$this
->assertText(t('Saved @name configuration.', array(
'@name' => $details['label'],
)));
}