function EditorAdminTest::testNoEditorAvailable

Same name in other branches
  1. 9 core/modules/editor/tests/src/Functional/EditorAdminTest.php \Drupal\Tests\editor\Functional\EditorAdminTest::testNoEditorAvailable()
  2. 8.9.x core/modules/editor/tests/src/Functional/EditorAdminTest.php \Drupal\Tests\editor\Functional\EditorAdminTest::testNoEditorAvailable()
  3. 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 59

Class

EditorAdminTest
Tests administration of text editors.

Namespace

Drupal\Tests\editor\Functional

Code

public function testNoEditorAvailable() : void {
    $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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.