You are here

protected function EditorAdminTest::selectUnicornEditor in Drupal 8

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

Tests and selects the unicorn editor.

Return value

array Returns an edit array containing the values to be posted.

3 calls to EditorAdminTest::selectUnicornEditor()
EditorAdminTest::addEditorToNewFormat in core/modules/editor/tests/src/Functional/EditorAdminTest.php
Adds an editor to a new format using the UI.
EditorAdminTest::testAddEditorToExistingFormat in core/modules/editor/tests/src/Functional/EditorAdminTest.php
Tests adding a text editor to an existing text format.
EditorAdminTest::testSwitchEditorToNone in core/modules/editor/tests/src/Functional/EditorAdminTest.php
Tests switching text editor to none does not throw a TypeError.

File

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

Class

EditorAdminTest
Tests administration of text editors.

Namespace

Drupal\Tests\editor\Functional

Code

protected function selectUnicornEditor() {

  // Verify the <select> when a text editor is available.
  $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
    ->assertCount(1, $select, 'The Text Editor select exists.');
  $this
    ->assertCount(0, $select_is_disabled, 'The Text Editor select is not disabled.');
  $this
    ->assertCount(2, $options, 'The Text Editor select has two options.');
  $this
    ->assertTrue($options[0]
    ->getText() === 'None', 'Option 1 in the Text Editor select is "None".');
  $this
    ->assertTrue($options[1]
    ->getText() === 'Unicorn Editor', 'Option 2 in the Text Editor select is "Unicorn Editor".');
  $this
    ->assertTrue($options[0]
    ->hasAttribute('selected'), 'Option 1 ("None") is selected.');

  // Ensure the none option is selected.
  $this
    ->assertNoRaw('This option is disabled because no modules that provide a text editor are currently enabled.', 'Description for select absent that tells users to install a text editor module.');

  // Select the "Unicorn Editor" editor and click the "Configure" button.
  $edit = [
    'editor[editor]' => 'unicorn',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Configure');
  $unicorn_setting = $this
    ->xpath('//input[@name="editor[settings][ponies_too]" and @type="checkbox" and @checked]');
  $this
    ->assertCount(1, $unicorn_setting, "Unicorn Editor's settings form is present.");
  return $edit;
}