You are here

public function QuickEditIntegrationTest::testEditorSelection in Drupal 8

Tests editor selection when the Editor module is present.

Tests a textual field, with text filtering, with cardinality 1 and >1, always with a ProcessedTextEditor plug-in present, but with varying text format compatibility.

File

core/modules/editor/tests/src/Kernel/QuickEditIntegrationTest.php, line 141

Class

QuickEditIntegrationTest
Tests Edit module integration (Editor module's inline editing support).

Namespace

Drupal\Tests\editor\Kernel

Code

public function testEditorSelection() {
  $this->editorManager = $this->container
    ->get('plugin.manager.quickedit.editor');
  $this->editorSelector = $this->container
    ->get('quickedit.editor.selector');

  // Create an entity with values for this text field.
  $entity = EntityTest::create();
  $entity->{$this->fieldName}->value = 'Hello, world!';
  $entity->{$this->fieldName}->format = 'filtered_html';
  $entity
    ->save();

  // Editor selection w/ cardinality 1, text format w/o associated text editor.
  $this
    ->assertEqual('form', $this
    ->getSelectedEditor($entity
    ->id(), $this->fieldName), "With cardinality 1, and the filtered_html text format, the 'form' editor is selected.");

  // Editor selection w/ cardinality 1, text format w/ associated text editor.
  $entity->{$this->fieldName}->format = 'full_html';
  $entity
    ->save();
  $this
    ->assertEqual('editor', $this
    ->getSelectedEditor($entity
    ->id(), $this->fieldName), "With cardinality 1, and the full_html text format, the 'editor' editor is selected.");

  // Editor selection with text processing, cardinality >1
  $this->fields->field_textarea_field_storage
    ->setCardinality(2);
  $this->fields->field_textarea_field_storage
    ->save();
  $this
    ->assertEqual('form', $this
    ->getSelectedEditor($entity
    ->id(), $this->fieldName), "With cardinality >1, and both items using the full_html text format, the 'form' editor is selected.");
}