You are here

protected function RequiredByRoleEmailFieldWebTestCase::createEmailField in Required by role 7

Helper function to create an email field.

1 call to RequiredByRoleEmailFieldWebTestCase::createEmailField()
RequiredByRoleEmailFieldWebTestCase::setUp in tests/required_by_role_test/RequiredByRoleEmailFieldWebTestCase.test
Setup method.

File

tests/required_by_role_test/RequiredByRoleEmailFieldWebTestCase.test, line 69
Tests for the Email field.

Class

RequiredByRoleEmailFieldWebTestCase
@file Tests for the Email field.

Code

protected function createEmailField($bundle = NULL, $settings = array()) {
  $node_type = $bundle ? $bundle : $this->entity_bundle;
  $name = 'email_test_' . strtolower($this
    ->randomName(4));
  $label = $this->field_label;
  $edit = array(
    'fields[_add_new_field][label]' => $label,
    'fields[_add_new_field][field_name]' => $name,
    'fields[_add_new_field][type]' => 'email',
    'fields[_add_new_field][widget_type]' => 'email_textfield',
  );
  $field_name = 'field_' . $name;
  $this
    ->drupalPost('admin/structure/types/manage/' . $node_type . '/fields', $edit, t('Save'));
  $this
    ->drupalPost(NULL, array(), t('Save field settings'));
  $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;
}