protected function RequiredByRoleCommonWebTestCase::createTextField in Required by role 7.2
Same name and namespace in other branches
- 7 tests/required_by_role_test/RequiredByRoleCommonWebTestCase.test \RequiredByRoleCommonWebTestCase::createTextField()
Helper function to create an email field.
1 call to RequiredByRoleCommonWebTestCase::createTextField()
- RequiredByRoleCommonWebTestCase::setUp in tests/
required_by_role_test/ RequiredByRoleCommonWebTestCase.test - Setup method.
File
- tests/
required_by_role_test/ RequiredByRoleCommonWebTestCase.test, line 103 - Tests for the common cases.
Class
- RequiredByRoleCommonWebTestCase
- @file Tests for the common cases.
Code
protected function createTextField($bundle = NULL, $settings = array()) {
$node_type = $bundle ? $bundle : $this->entity_bundle;
$label = $this
->getFieldLabel();
$name = $this
->getFieldName();
$edit = array(
'fields[_add_new_field][label]' => $label,
'fields[_add_new_field][field_name]' => $name,
'fields[_add_new_field][type]' => 'text',
'fields[_add_new_field][widget_type]' => 'text_textfield',
);
$field_name = $this
->getFieldMachineName();
$this
->drupalPost('admin/structure/types/manage/' . $node_type . '/fields', $edit, t('Save'));
$this
->drupalPost(NULL, array(), t('Save field settings'));
$plugin = array(
'instance[settings][required_plugin]' => 'by_role',
);
$this
->drupalPostAJAX(NULL, $plugin, 'instance[settings][required_plugin]');
$this
->drupalPost(NULL, $settings, t('Save settings'));
// Is field created?
$this
->assertRaw(t('Saved %label configuration', array(
'%label' => $label,
)), 'Field added');
node_types_rebuild();
menu_rebuild();
return $field_name;
}