public function FieldPlaceholderTestCase::testPlaceholderBasic in Field placeholder 7.2
Same name and namespace in other branches
- 7 field_placeholder.test \FieldPlaceholderTestCase::testPlaceholderBasic()
Performs the basic tests.
File
- ./
field_placeholder.test, line 89 - File that holds functional tests for Field placeholder module.
Class
- FieldPlaceholderTestCase
- @file File that holds functional tests for Field placeholder module.
Code
public function testPlaceholderBasic() {
$bundle_path1 = 'admin/structure/types/manage/' . $this->hyphen_type;
// Create a basic text field.
$edit = array(
'fields[_add_new_field][type]' => 'text',
'fields[_add_new_field][widget_type]' => 'text_textfield',
'fields[_add_new_field][label]' => 'Text',
'fields[_add_new_field][field_name]' => 'text',
);
$instance_settings = array(
'instance[placeholder]' => 'Textfield placeholder',
);
$this
->fieldUIAddNewField($bundle_path1, $edit, array(), $instance_settings);
// Create a long text field.
$edit = array(
'fields[_add_new_field][type]' => 'text_long',
'fields[_add_new_field][widget_type]' => 'text_textarea',
'fields[_add_new_field][label]' => 'Long text',
'fields[_add_new_field][field_name]' => 'longtext',
);
$instance_settings = array(
'instance[placeholder]' => 'Textarea placeholder',
);
$this
->fieldUIAddNewField($bundle_path1, $edit, array(), $instance_settings);
// Create a long text with summary field.
$edit = array(
'fields[_add_new_field][type]' => 'text_with_summary',
'fields[_add_new_field][widget_type]' => 'text_textarea_with_summary',
'fields[_add_new_field][label]' => 'Text with summary',
'fields[_add_new_field][field_name]' => 'summary',
);
$instance_settings = array(
'instance[placeholder]' => 'Summary placeholder',
'instance[settings][display_summary]' => 1,
);
$this
->fieldUIAddNewField($bundle_path1, $edit, array(), $instance_settings);
// Create an integer field.
$edit = array(
'fields[_add_new_field][type]' => 'number_integer',
'fields[_add_new_field][widget_type]' => 'number',
'fields[_add_new_field][label]' => 'Number',
'fields[_add_new_field][field_name]' => 'integer',
);
$instance_settings = array(
'instance[placeholder]' => 'Integer placeholder',
);
$this
->fieldUIAddNewField($bundle_path1, $edit, array(), $instance_settings);
// Go to node creation page.
$this
->drupalGet('node/add/' . $this->hyphen_type);
// Assertions.
$this
->assertRaw('placeholder="Textfield placeholder"', 'Text field placeholder displayed');
$this
->assertRaw('placeholder="Textarea placeholder"', 'Textarea field placeholder displayed');
$this
->assertRaw('placeholder="Summary placeholder"', 'Text with summary field placeholder displayed');
$this
->assertRaw('placeholder="Integer placeholder"', 'Integer field placeholder displayed');
// Test Label as placeholder feature.
$edit = array(
'instance[use_title_as_placeholder]' => 1,
);
$field_types = array(
'text',
'longtext',
'summary',
'integer',
);
foreach ($field_types as $field_type) {
$this
->drupalPost('admin/structure/types/manage/' . $this->hyphen_type . '/fields/field_' . $field_type, $edit, t('Save settings'));
}
// Go to node creation page.
$this
->drupalGet('node/add/' . $this->hyphen_type);
// Assertions.
$this
->assertRaw('placeholder="Text"', 'Text field placeholder displayed');
$this
->assertRaw('placeholder="Long text"', 'Textarea field placeholder displayed');
$this
->assertRaw('placeholder="Text with summary"', 'Text with summary field placeholder displayed');
$this
->assertRaw('placeholder="Number"', 'Integer field placeholder displayed');
}