diff --git a/core/modules/edit/lib/Drupal/edit/MetadataGenerator.php b/core/modules/edit/lib/Drupal/edit/MetadataGenerator.php index 3ec8ce2..df0217a 100644 --- a/core/modules/edit/lib/Drupal/edit/MetadataGenerator.php +++ b/core/modules/edit/lib/Drupal/edit/MetadataGenerator.php @@ -69,8 +69,7 @@ public function generate(EntityInterface $entity, FieldInstance $instance, $lang // Early-return if no editor is available. $formatter_id = entity_get_render_display($entity, $view_mode)->getFormatter($instance['field_name'])->getPluginId(); - $items = $entity->get($field_name); - $items = $items[$langcode]; + $items = $entity->getTranslation($langcode)->get($field_name)->getValue(); $editor_id = $this->editorSelector->getEditor($formatter_id, $instance, $items); if (!isset($editor_id)) { return array('access' => FALSE); diff --git a/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php b/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php index c3a91fb..d614829 100644 --- a/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php +++ b/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php @@ -20,8 +20,7 @@ class EditTestBase extends DrupalUnitTestBase { * * @var array */ - public static $modules = array('system', 'entity', 'field', 'field_sql_storage', 'field_test', 'number', 'text', 'edit'); - + public static $modules = array('system', 'entity', 'entity_test', 'field', 'field_sql_storage', 'field_test', 'number', 'text', 'edit'); /** * Sets the default field storage backend for fields created during tests. */ @@ -30,7 +29,7 @@ function setUp() { $this->installSchema('system', 'variable'); $this->installSchema('field', array('field_config', 'field_config_instance')); - $this->installSchema('field_test', 'test_entity'); + $this->installSchema('entity_test', 'entity_test'); // Set default storage backend. variable_set('field_storage_default', $this->default_storage); @@ -69,8 +68,8 @@ function createFieldWithInstance($field_name, $type, $cardinality, $label, $inst $instance = $field_name . '_instance'; $this->$instance = array( 'field_name' => $field_name, - 'entity_type' => 'test_entity', - 'bundle' => 'test_bundle', + 'entity_type' => 'entity_test', + 'bundle' => 'entity_test', 'label' => $label, 'description' => $label, 'weight' => mt_rand(0, 127), @@ -83,7 +82,7 @@ function createFieldWithInstance($field_name, $type, $cardinality, $label, $inst ); field_create_instance($this->$instance); - entity_get_display('test_entity', 'test_bundle', 'default') + entity_get_display('entity_test', 'entity_test', 'default') ->setComponent($field_name, array( 'label' => 'above', 'type' => $formatter_type, diff --git a/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php b/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php index fdddec0..e7a6db1 100644 --- a/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php +++ b/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php @@ -49,8 +49,8 @@ function setUp() { * editor that Edit selects. */ protected function getSelectedEditor($items, $field_name, $view_mode = 'default') { - $options = entity_get_display('test_entity', 'test_bundle', $view_mode)->getComponent($field_name); - $field_instance = field_info_instance('test_entity', $field_name, 'test_bundle'); + $options = entity_get_display('entity_test', 'entity_test', $view_mode)->getComponent($field_name); + $field_instance = field_info_instance('entity_test', $field_name, 'entity_test'); return $this->editorSelector->getEditor($options['type'], $field_instance, $items); } diff --git a/core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php b/core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php index 529d535..e41e6ed 100644 --- a/core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php +++ b/core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php @@ -96,12 +96,12 @@ function testSimpleEntityType() { ); // Create an entity with values for this text field. - $this->entity = field_test_create_entity(); + $this->entity = entity_create('entity_test', array()); $this->is_new = TRUE; - $this->entity->{$field_1_name}[LANGUAGE_NOT_SPECIFIED] = array(array('value' => 'Test')); - $this->entity->{$field_2_name}[LANGUAGE_NOT_SPECIFIED] = array(array('value' => 42)); - field_test_entity_save($this->entity); - $entity = entity_load('test_entity', $this->entity->ftid); + $this->entity->{$field_1_name}->value = 'Test'; + $this->entity->{$field_2_name}->value = 42; + $this->entity->save(); + $entity = entity_load('entity_test', $this->entity->id()); // Verify metadata for field 1. $instance_1 = field_info_instance($entity->entityType(), $field_1_name, $entity->bundle()); @@ -110,7 +110,7 @@ function testSimpleEntityType() { 'access' => TRUE, 'label' => 'Simple text field', 'editor' => 'direct', - 'aria' => 'Entity test_entity 1, field Simple text field', + 'aria' => 'Entity entity_test 1, field Simple text field', ); $this->assertEqual($expected_1, $metadata_1, 'The correct metadata is generated for the first field.'); @@ -121,7 +121,7 @@ function testSimpleEntityType() { 'access' => TRUE, 'label' => 'Simple number field', 'editor' => 'form', - 'aria' => 'Entity test_entity 1, field Simple number field', + 'aria' => 'Entity entity_test 1, field Simple number field', ); $this->assertEqual($expected_2, $metadata_2, 'The correct metadata is generated for the second field.'); } @@ -164,11 +164,11 @@ function testEditorWithCustomMetadata() { $full_html_format->save(); // Create an entity with values for this rich text field. - $this->entity = field_test_create_entity(); - $this->is_new = TRUE; - $this->entity->{$field_name}[LANGUAGE_NOT_SPECIFIED] = array(array('value' => 'Test', 'format' => 'full_html')); - field_test_entity_save($this->entity); - $entity = entity_load('test_entity', $this->entity->ftid); + $this->entity = entity_create('entity_test', array()); + $this->entity->{$field_name}->value = 'Test'; + $this->entity->{$field_name}->format = 'full_html'; + $this->entity->save(); + $entity = entity_load('entity_test', $this->entity->id()); // Verify metadata. $instance = field_info_instance($entity->entityType(), $field_name, $entity->bundle()); @@ -177,7 +177,7 @@ function testEditorWithCustomMetadata() { 'access' => TRUE, 'label' => 'Rich text field', 'editor' => 'wysiwyg', - 'aria' => 'Entity test_entity 1, field Rich text field', + 'aria' => 'Entity entity_test 1, field Rich text field', 'custom' => array( 'format' => 'full_html' ),