public function QuickEditIntegrationTest::testMetadata in Drupal 8
Tests (custom) metadata when the formatted text editor is used.
File
- core/
modules/ editor/ tests/ src/ Kernel/ QuickEditIntegrationTest.php, line 168
Class
- QuickEditIntegrationTest
- Tests Edit module integration (Editor module's inline editing support).
Namespace
Drupal\Tests\editor\KernelCode
public function testMetadata() {
$this->editorManager = $this->container
->get('plugin.manager.quickedit.editor');
$this->accessChecker = new MockQuickEditEntityFieldAccessCheck();
$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 = EntityTest::create();
$entity->{$this->fieldName}->value = 'Test';
$entity->{$this->fieldName}->format = 'full_html';
$entity
->save();
$entity = EntityTest::load($entity
->id());
// Verify metadata.
$items = $entity
->get($this->fieldName);
$metadata = $this->metadataGenerator
->generateFieldMetadata($items, 'default');
$expected = [
'access' => TRUE,
'label' => 'Long text field',
'editor' => 'editor',
'custom' => [
'format' => 'full_html',
'formatHasTransformations' => FALSE,
],
];
$this
->assertEqual($expected, $metadata, 'The correct metadata (including custom metadata) is generated.');
}