Issue #1942000 by Wim Leers: Node NG broke Edit module.
parent
12df490cbd
commit
45f4327584
|
@ -69,8 +69,7 @@ class MetadataGenerator implements MetadataGeneratorInterface {
|
|||
|
||||
// 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, FALSE)->get($field_name)->getValue();
|
||||
$editor_id = $this->editorSelector->getEditor($formatter_id, $instance, $items);
|
||||
if (!isset($editor_id)) {
|
||||
return array('access' => FALSE);
|
||||
|
|
|
@ -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 @@ class EditTestBase extends DrupalUnitTestBase {
|
|||
|
||||
$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 @@ class EditTestBase extends DrupalUnitTestBase {
|
|||
$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 @@ class EditTestBase extends DrupalUnitTestBase {
|
|||
);
|
||||
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,
|
||||
|
|
|
@ -49,8 +49,8 @@ class EditorSelectionTest extends EditTestBase {
|
|||
* 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -96,12 +96,12 @@ class MetadataGeneratorTest extends EditTestBase {
|
|||
);
|
||||
|
||||
// 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 @@ class MetadataGeneratorTest extends EditTestBase {
|
|||
'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 @@ class MetadataGeneratorTest extends EditTestBase {
|
|||
'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 @@ class MetadataGeneratorTest extends EditTestBase {
|
|||
$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 @@ class MetadataGeneratorTest extends EditTestBase {
|
|||
'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'
|
||||
),
|
||||
|
|
Loading…
Reference in New Issue