From 958056da9b91abe7801b37a310dd21be027f77e7 Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Fri, 29 Nov 2013 13:13:23 +0000 Subject: [PATCH] Issue #2115291 by plopesc, agentrickard: Field types must use as provider its own module instead of Core when are defined in hook_field_info_alter(). --- core/modules/email/email.module | 1 + .../lib/Drupal/email/Tests/EmailFieldTest.php | 18 +++++++++++------- .../entity_reference/entity_reference.module | 1 + .../EntityReferenceFieldDefaultValueTest.php | 3 +++ 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/core/modules/email/email.module b/core/modules/email/email.module index bee295c3db5559a8..f74da6f085447d1b 100644 --- a/core/modules/email/email.module +++ b/core/modules/email/email.module @@ -41,6 +41,7 @@ function email_field_info_alter(&$info) { else { $info['email']['default_formatter'] = 'email_mailto'; } + $info['email']['provider'] = 'email'; } /** diff --git a/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php b/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php index 60fd532ad7cf7335..ad1ec2ed6be8ac0b 100644 --- a/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php +++ b/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php @@ -90,6 +90,9 @@ class EmailFieldTest extends WebTestBase { )) ->save(); + // Rebuild field info to check if email field still working. + field_sync_field_status(); + // Display creation form. $this->drupalGet('entity_test/add'); $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget found.'); @@ -106,13 +109,14 @@ class EmailFieldTest extends WebTestBase { preg_match('|entity_test/manage/(\d+)|', $this->url, $match); $id = $match[1]; $this->assertText(t('entity_test @id has been created.', array('@id' => $id))); - $this->assertRaw($value); - // Verify that a mailto link is displayed. - $entity = entity_load('entity_test', $id); - $display = entity_get_display($entity->entityType(), $entity->bundle(), 'full'); - $entity->content = field_attach_view($entity, $display); - $this->drupalSetContent(drupal_render($entity->content)); - $this->assertLinkByHref('mailto:test@example.com'); + if ($this->assertRaw($value)) { + // Verify that a mailto link is displayed. + $entity = entity_load('entity_test', $id); + $display = entity_get_display($entity->entityType(), $entity->bundle(), 'full'); + $entity->content = field_attach_view($entity, $display); + $this->drupalSetContent(drupal_render($entity->content)); + $this->assertLinkByHref('mailto:test@example.com'); + } } } diff --git a/core/modules/entity_reference/entity_reference.module b/core/modules/entity_reference/entity_reference.module index 6461ec445342722b..d52ba4c95071ef6c 100644 --- a/core/modules/entity_reference/entity_reference.module +++ b/core/modules/entity_reference/entity_reference.module @@ -25,6 +25,7 @@ function entity_reference_field_info_alter(&$info) { $info['entity_reference']['default_widget'] = 'entity_reference_autocomplete'; $info['entity_reference']['default_formatter'] = 'entity_reference_label'; $info['entity_reference']['list_class'] = '\Drupal\entity_reference\Plugin\Field\FieldType\ConfigurableEntityReferenceFieldItemList'; + $info['entity_reference']['provider'] = 'entity_reference'; } /** diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFieldDefaultValueTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFieldDefaultValueTest.php index 7d61f3d62e2f8919..d5271fc45abee4e2 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFieldDefaultValueTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFieldDefaultValueTest.php @@ -69,6 +69,9 @@ class EntityReferenceFieldDefaultValueTest extends WebTestBase { )); $this->instance->save(); + // Rebuild field info to check if entity_reference field still working. + field_sync_field_status(); + // Set created node as default_value. $instance_edit = array( 'default_value_input[' . $this->field->name . '][0][target_id]' => $referenced_node->getTitle() . ' (' .$referenced_node->id() . ')',