function testEditorWithCustomMetadata() {
$this
->installSchema('system', 'url_alias');
$this
->enableModules(array(
'user',
'filter',
));
// Enable edit_test module so that the WYSIWYG editor becomes available.
$this
->enableModules(array(
'edit_test',
));
// Create a rich text field.
$field_name = 'field_rich';
$field_label = 'Rich text field';
$this
->createFieldWithInstance($field_name, 'text', 1, $field_label, array(
'text_processing' => 1,
), 'text_textfield', array(
'size' => 42,
), 'text_default', array());
// Create a text format.
$full_html_format = entity_create('filter_format', array(
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
'filters' => array(
'filter_htmlcorrector' => array(
'status' => 1,
),
),
));
$full_html_format
->save();
// Create an entity with values for this rich text field.
$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());
$metadata = $this->metadataGenerator
->generate($entity, $instance, Language::LANGCODE_NOT_SPECIFIED, 'default');
$expected = array(
'access' => TRUE,
'label' => 'Rich text field',
'editor' => 'wysiwyg',
'aria' => 'Entity entity_test 1, field Rich text field',
'custom' => array(
'format' => 'full_html',
),
);
$this
->assertEqual($expected, $metadata, 'The correct metadata (including custom metadata) is generated.');
}