You are here

protected function WidgetTestTrait::assertWidgetForm in The CodeMirror Editor 8

Asserts widget form.

1 call to WidgetTestTrait::assertWidgetForm()
WidgetTestTrait::testWidgetEditor in tests/src/FunctionalJavascript/WidgetTestTrait.php
Test callback.

File

tests/src/FunctionalJavascript/WidgetTestTrait.php, line 107

Class

WidgetTestTrait
Provides a helper methods to for testing widgets.

Namespace

Drupal\Tests\codemirror_editor\FunctionalJavascript

Code

protected function assertWidgetForm(array $widget_settings) {
  $xpath = sprintf('//textarea[@name = "' . $this->fieldName . '[0][value]" and @rows = %d and @placeholder = "%s"]', $widget_settings['rows'], $widget_settings['placeholder']);
  $this
    ->assertSession()
    ->elementExists('xpath', $xpath);
  $widget_settings['toolbar'] ? $this
    ->assertToolbarExists() : $this
    ->assertToolbarNotExists();

  // 'buttons' is not available from cm.getOption().
  if (!empty($widget_settings['buttons'])) {
    foreach ($widget_settings['buttons'] as $button) {
      $this
        ->assertSession()
        ->elementExists('xpath', "//*[@data-cme-button='" . $button . "']");
    }
  }
  $this
    ->assertEditorOption('mode', $widget_settings['mode']);
  $this
    ->assertEditorOption('lineWrapping', $widget_settings['lineWrapping']);
  $this
    ->assertEditorOption('lineNumbers', $widget_settings['lineNumbers']);
  $this
    ->assertEditorOption('foldGutter', $widget_settings['foldGutter']);
  $this
    ->assertEditorOption('autoCloseTags', $widget_settings['autoCloseTags']);
  $this
    ->assertEditorOption('styleActiveLine', $widget_settings['styleActiveLine']);
}