You are here

public function EditorAdminTest::testNoEditorAvailable in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/editor/tests/src/Functional/EditorAdminTest.php \Drupal\Tests\editor\Functional\EditorAdminTest::testNoEditorAvailable()
  2. 10 core/modules/editor/tests/src/Functional/EditorAdminTest.php \Drupal\Tests\editor\Functional\EditorAdminTest::testNoEditorAvailable()

Tests an existing format without any editors available.

File

core/modules/editor/tests/src/Functional/EditorAdminTest.php, line 56

Class

EditorAdminTest
Tests administration of text editors.

Namespace

Drupal\Tests\editor\Functional

Code

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

  // Ensure the form field order is correct.
  $raw_content = $this
    ->getSession()
    ->getPage()
    ->getContent();
  $roles_pos = strpos($raw_content, 'Roles');
  $editor_pos = strpos($raw_content, 'Text editor');
  $filters_pos = strpos($raw_content, 'Enabled filters');
  $this
    ->assertGreaterThan($roles_pos, $editor_pos);
  $this
    ->assertLessThan($filters_pos, $editor_pos);

  // Verify the <select>.
  $select = $this
    ->assertSession()
    ->selectExists('editor[editor]');
  $this
    ->assertSame('disabled', $select
    ->getAttribute('disabled'));
  $options = $select
    ->findAll('css', 'option');
  $this
    ->assertCount(1, $options);
  $this
    ->assertSame('None', $options[0]
    ->getText(), 'Option 1 in the Text Editor select is "None".');
  $this
    ->assertSession()
    ->pageTextContains('This option is disabled because no modules that provide a text editor are currently enabled.');
}