/**
  * Tests a field whose associated in-place editor generates custom metadata.
  */
 public function testEditorWithCustomMetadata()
 {
     $this->installSchema('system', 'url_alias');
     $this->editorManager = $this->container->get('plugin.manager.quickedit.editor');
     $this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter'));
     $this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager);
     $this->editorManager = $this->container->get('plugin.manager.quickedit.editor');
     $this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter'));
     $this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager);
     // Create a rich text field.
     $field_name = 'field_rich';
     $field_label = 'Rich text field';
     $this->createFieldWithStorage($field_name, 'text', 1, $field_label, array(), '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.
     $entity = entity_create('entity_test');
     $entity->{$field_name}->value = 'Test';
     $entity->{$field_name}->format = 'full_html';
     $entity->save();
     $entity = entity_load('entity_test', $entity->id());
     // Verify metadata.
     $items = $entity->get($field_name);
     $metadata = $this->metadataGenerator->generateFieldMetadata($items, 'default');
     $expected = array('access' => TRUE, 'label' => 'Rich text field', 'editor' => 'wysiwyg', 'custom' => array('format' => 'full_html'));
     $this->assertEqual($expected, $metadata);
     //, 'The correct metadata (including custom metadata) is generated.');
 }
 /**
  * Tests a field whose associated in-place editor generates custom metadata.
  */
 public 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('quickedit_test'));
     $this->editorManager = $this->container->get('plugin.manager.quickedit.editor');
     $this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter'));
     $this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager);
     $this->editorManager = $this->container->get('plugin.manager.quickedit.editor');
     $this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter'));
     $this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager);
     // 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');
     $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.
     $items = $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get($field_name);
     $metadata = $this->metadataGenerator->generateFieldMetadata($items, '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.');
 }
 /**
  * Tests (custom) metadata when the formatted text editor is used.
  */
 public function testMetadata()
 {
     $this->editorManager = $this->container->get('plugin.manager.quickedit.editor');
     $this->accessChecker = new MockEditEntityFieldAccessCheck();
     $this->editorSelector = $this->container->get('quickedit.editor.selector');
     $this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager);
     // Create an entity with values for the field.
     $entity = entity_create('entity_test');
     $entity->{$this->fieldName}->value = 'Test';
     $entity->{$this->fieldName}->format = 'full_html';
     $entity->save();
     $entity = entity_load('entity_test', $entity->id());
     // Verify metadata.
     $items = $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get($this->fieldName);
     $metadata = $this->metadataGenerator->generateFieldMetadata($items, 'default');
     $expected = array('access' => TRUE, 'label' => 'Long text field', 'editor' => 'editor', 'aria' => 'Entity entity_test 1, field Long text field', 'custom' => array('format' => 'full_html', 'formatHasTransformations' => FALSE));
     $this->assertEqual($expected, $metadata, 'The correct metadata (including custom metadata) is generated.');
 }