function EditIntegrationTest::testEditorSelection

Tests editor selection when the Editor module is present.

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

File

drupal/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php, line 125
Contains \Drupal\editor\Tests\EditorIntegrationTest.

Class

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

Namespace

Drupal\editor\Tests

Code

function testEditorSelection() {
  $this->editorManager = new InPlaceEditorManager($this->container
    ->get('container.namespaces'));
  $this->editorSelector = new EditorSelector($this->editorManager);

  // Pretend there is an entity with these items for the field.
  $items = array(
    array(
      'value' => 'Hello, world!',
      'format' => 'filtered_html',
    ),
  );

  // Editor selection w/ cardinality 1, text format w/o associated text editor.
  $this
    ->assertEqual('form', $this
    ->getSelectedEditor($items, $this->field_name), "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.
  $items[0]['format'] = 'full_html';
  $this
    ->assertEqual('editor', $this
    ->getSelectedEditor($items, $this->field_name), "With cardinality 1, and the full_html text format, the 'editor' editor is selected.");

  // Editor selection with text processing, cardinality >1
  $this->field_textarea_field['cardinality'] = 2;
  field_update_field($this->field_textarea_field);
  $items[] = array(
    'value' => 'Hallo, wereld!',
    'format' => 'full_html',
  );
  $this
    ->assertEqual('form', $this
    ->getSelectedEditor($items, $this->field_name), "With cardinality >1, and both items using the full_html text format, the 'form' editor is selected.");
}