You are here

public function QuickEditIntegrationTest::testEditorSelection in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/editor/src/Tests/QuickEditIntegrationTest.php \Drupal\editor\Tests\QuickEditIntegrationTest::testEditorSelection()

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/src/Tests/QuickEditIntegrationTest.php, line 130
Contains \Drupal\editor\Tests\QuickEditIntegrationTest.

Class

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

Namespace

Drupal\editor\Tests

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 = entity_create('entity_test');
  $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.");
}