protected function EditorAdminTest::selectUnicornEditor

Tests and selects the unicorn editor.

Return value

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

2 calls to EditorAdminTest::selectUnicornEditor()
EditorAdminTest::testAddEditorToExistingFormat in drupal/core/modules/editor/lib/Drupal/editor/Tests/EditorAdminTest.php
Tests adding a text editor to an existing text format.
EditorAdminTest::testAddEditorToNewFormat in drupal/core/modules/editor/lib/Drupal/editor/Tests/EditorAdminTest.php
Tests adding a text editor to a new text format.

File

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

Class

EditorAdminTest
Tests administration of text editors.

Namespace

Drupal\editor\Tests

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
    ->assertTrue(count($select) === 1, 'The Text Editor select exists.');
  $this
    ->assertTrue(count($select_is_disabled) === 0, 'The Text Editor select is not disabled.');
  $this
    ->assertTrue(count($options) === 2, 'The Text Editor select has two options.');
  $this
    ->assertTrue((string) $options[0] === 'None', 'Option 1 in the Text Editor select is "None".');
  $this
    ->assertTrue((string) $options[1] === 'Unicorn Editor', 'Option 2 in the Text Editor select is "Unicorn Editor".');
  $this
    ->assertTrue((string) $options[0]['selected'] === 'selected', 'Option 1 ("None") is selected.');

  // Ensure the none option is selected
  $this
    ->assertNoRaw(t('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 = array(
    'editor[editor]' => 'unicorn',
  );
  $this
    ->drupalPostAjax(NULL, $edit, 'editor_configure');
  $unicorn_setting_foo = $this
    ->xpath('//input[@name="editor[settings][foo]" and @type="text" and @value="bar"]');
  $this
    ->assertTrue(count($unicorn_setting_foo), "Unicorn Editor's settings form is present.");
  return $edit;
}