You are here

protected function TestBase::assertWidgetSettingsForm in Twig Field 8

Asserts widget settings form.

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

File

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

Class

TestBase
Base class for Twig field tests.

Namespace

Drupal\Tests\twig_field\FunctionalJavascript

Code

protected function assertWidgetSettingsForm(array $widget_settings) {
  $assert_session = $this
    ->assertSession();
  $settings_wrapper = $assert_session
    ->waitForElementVisible('xpath', '//div[@data-drupal-selector = "edit-fields-field-template-settings-edit-form"]');
  self::assertNotNull($settings_wrapper);
  $xpath = '//input[@name = "fields[field_template][settings_edit_form][settings][rows]" and @value = %d]';
  $xpath = sprintf($xpath, $widget_settings['rows']);
  $assert_session
    ->elementExists('xpath', $xpath, $settings_wrapper);
  $xpath = '//input[@name = "fields[field_template][settings_edit_form][settings][placeholder]" and @value = "%s"]';
  $xpath = sprintf($xpath, $widget_settings['placeholder']);
  $assert_session
    ->elementExists('xpath', $xpath, $settings_wrapper);
  $xpath = '//input[@name = "fields[field_template][settings_edit_form][settings][toolbar]" and %s]';
  $xpath = sprintf($xpath, $widget_settings['toolbar'] ? '@checked = "checked"' : 'not(@checked)');
  $assert_session
    ->elementExists('xpath', $xpath, $settings_wrapper);
  $xpath = '//input[@name = "fields[field_template][settings_edit_form][settings][lineWrapping]" and %s]';
  $xpath = sprintf($xpath, $widget_settings['lineWrapping'] ? '@checked = "checked"' : 'not(@checked)');
  $assert_session
    ->elementExists('xpath', $xpath, $settings_wrapper);
  $xpath = '//input[@name = "fields[field_template][settings_edit_form][settings][lineNumbers]" and %s]';
  $xpath = sprintf($xpath, $widget_settings['lineNumbers'] ? '@checked = "checked"' : 'not(@checked)');
  $assert_session
    ->elementExists('xpath', $xpath, $settings_wrapper);
  $xpath = '//input[@name = "fields[field_template][settings_edit_form][settings][foldGutter]" and %s]';
  $xpath = sprintf($xpath, $widget_settings['foldGutter'] ? '@checked = "checked"' : 'not(@checked)');
  $assert_session
    ->elementExists('xpath', $xpath, $settings_wrapper);
  $xpath = '//input[@name = "fields[field_template][settings_edit_form][settings][autoCloseTags]" and %s]';
  $xpath = sprintf($xpath, $widget_settings['autoCloseTags'] ? '@checked = "checked"' : 'not(@checked)');
  $assert_session
    ->elementExists('xpath', $xpath, $settings_wrapper);
  $xpath = '//input[@name = "fields[field_template][settings_edit_form][settings][styleActiveLine]" and %s]';
  $xpath = sprintf($xpath, $widget_settings['styleActiveLine'] ? '@checked = "checked"' : 'not(@checked)');
  $assert_session
    ->elementExists('xpath', $xpath, $settings_wrapper);
}