You are here

protected function WidgetTestTrait::assertWidgetSettingsSummary in The CodeMirror Editor 8

Asserts widget settings summary.

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

File

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

Class

WidgetTestTrait
Provides a helper methods to for testing widgets.

Namespace

Drupal\Tests\codemirror_editor\FunctionalJavascript

Code

protected function assertWidgetSettingsSummary(array $widget_settings) {
  $expected_summary[] = 'Number of rows: ' . $widget_settings['rows'];
  if ($widget_settings['placeholder']) {
    $expected_summary[] = 'Placeholder: ' . $widget_settings['placeholder'];
  }
  $expected_summary[] = 'Language mode: ' . $widget_settings['mode'];
  $expected_summary[] = 'Load toolbar: ' . ($widget_settings['toolbar'] ? 'Yes' : 'No');
  if ($widget_settings['toolbar']) {
    $expected_summary[] = 'Toolbar buttons: ' . implode(', ', $widget_settings['buttons']);
  }
  $expected_summary[] = 'Line wrapping: ' . ($widget_settings['lineWrapping'] ? 'Yes' : 'No');
  $expected_summary[] = 'Line numbers: ' . ($widget_settings['lineNumbers'] ? 'Yes' : 'No');
  $expected_summary[] = 'Fold gutter: ' . ($widget_settings['foldGutter'] ? 'Yes' : 'No');
  $expected_summary[] = 'Auto close tags: ' . ($widget_settings['autoCloseTags'] ? 'Yes' : 'No');
  $expected_summary[] = 'Style active line: ' . ($widget_settings['styleActiveLine'] ? 'Yes' : 'No');
  $summary_xpath = '//tr[@id = "' . Html::getClass($this->fieldName) . '"]//div[@class = "field-plugin-summary"]';
  $summary = $this
    ->xpath($summary_xpath)[0]
    ->getHtml();
  self::assertEquals(implode('<br>', $expected_summary), $summary);
}