You are here

protected function TestBase::assertWidgetSettingsSummary in Twig Field 8

Asserts widget settings summary.

1 call to TestBase::assertWidgetSettingsSummary()
TwigFieldTest::testTwigField in tests/src/FunctionalJavascript/TwigFieldTest.php
Test callback.

File

tests/src/FunctionalJavascript/TestBase.php, line 190

Class

TestBase
Base class for Twig field tests.

Namespace

Drupal\Tests\twig_field\FunctionalJavascript

Code

protected function assertWidgetSettingsSummary(array $widget_settings) {
  $summary = $this
    ->assertSession()
    ->waitForElement('css', '#field-template .field-plugin-summary');
  $this
    ->assertNotNull($summary);
  $expected_summary[] = 'Number of rows: ' . $widget_settings['rows'];
  if ($widget_settings['placeholder']) {
    $expected_summary[] = 'Placeholder: ' . $widget_settings['placeholder'];
  }
  $expected_summary[] = 'Load toolbar: ' . ($widget_settings['toolbar'] ? 'Yes' : 'No');
  $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 = "field-template"]//div[@class = "field-plugin-summary"]';
  $summary = $this
    ->xpath($summary_xpath)[0]
    ->getHtml();
  self::assertEquals(implode('<br>', $expected_summary), $summary);
}