diff --git a/core/modules/field/modules/email/email.module b/core/modules/field/modules/email/email.module index 22ad60a..82de686 100644 --- a/core/modules/field/modules/email/email.module +++ b/core/modules/field/modules/email/email.module @@ -6,6 +6,19 @@ */ /** + * Implements hook_help(). + */ +function email_help($path, $arg) { + switch ($path) { + case 'admin/help#email': + $output = ''; + $output .= '

' . t('About') . '

'; + $output .= '

' . t('The E-mail module defines a field for storing e-mail addresses, for use with the Field module. E-mail addresses are validated to ensure they match the expected format. See the Field module help page for more information about fields.', array('@field-help' => url('admin/help/field'))) . '

'; + return $output; + } +} + +/** * Implements hook_field_info(). */ function email_field_info() { diff --git a/core/modules/field/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php b/core/modules/field/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php new file mode 100644 index 0000000..85130ea --- /dev/null +++ b/core/modules/field/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php @@ -0,0 +1,90 @@ + 'E-mail field', + 'description' => 'Test the creation of e-mail fields.', + 'group' => 'Field types' + ); + } + + function setUp() { + parent::setUp(); + + $this->web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content', 'administer content types')); + $this->drupalLogin($this->web_user); + } + + /** + * Test e-mail field. + */ + function testEmailField() { + // Create a field with settings to validate. + $this->field = array( + 'field_name' => drupal_strtolower($this->randomName()), + 'type' => 'email', + ); + field_create_field($this->field); + $this->instance = array( + 'field_name' => $this->field['field_name'], + 'entity_type' => 'test_entity', + 'bundle' => 'test_bundle', + 'widget' => array( + 'type' => 'email_default', + ), + 'display' => array( + 'full' => array( + 'type' => 'email_mailto', + ), + ), + ); + field_create_instance($this->instance); + + // Display creation form. + $this->drupalGet('test-entity/add/test_bundle'); + $langcode = LANGUAGE_NOT_SPECIFIED; + $this->assertFieldByName("{$this->field['field_name']}[$langcode][0][value]", '', t('Widget is displayed')); + + // Submit a signed decimal value within the allowed precision and scale. + $value = 'test@example.com'; + $edit = array( + "{$this->field['field_name']}[$langcode][0][value]" => $value, + ); + $this->drupalPost(NULL, $edit, t('Save')); + preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); + $id = $match[1]; + $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), t('Entity was created')); + $this->assertRaw($value, t('Value is displayed.')); + + //Check the formatting of the link: + $entity = field_test_entity_test_load($id); + $entity->content = field_attach_view('test_entity', $entity, 'full'); + $this->drupalSetContent(drupal_render($entity->content)); + $this->assertLinkByHref('mailto:test@example.com', 0, 'Mailto link is displayed'); + } +}