function EditorAdminTest::testNoEditorAvailable

Tests an existing format without any editors available.

File

drupal/core/modules/editor/lib/Drupal/editor/Tests/EditorAdminTest.php, line 51
Definition of \Drupal\editor\Tests\EditorAdminTest.

Class

EditorAdminTest
Tests administration of text editors.

Namespace

Drupal\editor\Tests

Code

function testNoEditorAvailable() {
  $this
    ->drupalLogin($this->admin_user);
  $this
    ->drupalGet('admin/config/content/formats/filtered_html');

  // Ensure the form field order is correct.
  $roles_pos = strpos($this
    ->drupalGetContent(), 'Roles');
  $editor_pos = strpos($this
    ->drupalGetContent(), 'Text editor');
  $filters_pos = strpos($this
    ->drupalGetContent(), 'Enabled filters');
  $this
    ->assertTrue($roles_pos < $editor_pos && $editor_pos < $filters_pos, '"Text Editor" select appears in the correct location of the text format configuration UI.');

  // Verify the <select>.
  $select = $this
    ->xpath('//select[@name="editor[editor]"]');
  $select_is_disabled = $this
    ->xpath('//select[@name="editor[editor]" and @disabled="disabled"]');
  $options = $this
    ->xpath('//select[@name="editor[editor]"]/option');
  $this
    ->assertTrue(count($select) === 1, 'The Text Editor select exists.');
  $this
    ->assertTrue(count($select_is_disabled) === 1, 'The Text Editor select is disabled.');
  $this
    ->assertTrue(count($options) === 1, 'The Text Editor select has only one option.');
  $this
    ->assertTrue((string) $options[0] === 'None', 'Option 1 in the Text Editor select is "None".');
  $this
    ->assertRaw(t('This option is disabled because no modules that provide a text editor are currently enabled.'), 'Description for select present that tells users to install a text editor module.');
}