protected function FormatterTest::assertFormatterSettingsForm in The CodeMirror Editor 8
Asserts formatter settings form.
1 call to FormatterTest::assertFormatterSettingsForm()
- FormatterTest::testFormatter in tests/
src/ FunctionalJavascript/ FormatterTest.php - Test callback.
File
- tests/
src/ FunctionalJavascript/ FormatterTest.php, line 122
Class
- FormatterTest
- Tests the CodeMirror field formatter.
Namespace
Drupal\Tests\codemirror_editor\FunctionalJavascriptCode
protected function assertFormatterSettingsForm(array $formatter_settings) {
$assert_session = $this
->assertSession();
$settings_wrapper = $assert_session
->waitForElementVisible('xpath', '//div[@data-drupal-selector = "edit-fields-field-code-settings-edit-form"]');
$xpath = '//select[@name = "fields[field_code][settings_edit_form][settings][mode]"]/optgroup/option[@value = "text/html" and @selected]';
$xpath = sprintf($xpath, $formatter_settings['mode']);
$assert_session
->elementExists('xpath', $xpath, $settings_wrapper);
$xpath = '//input[@name = "fields[field_code][settings_edit_form][settings][lineWrapping]" and %s]';
$xpath = sprintf($xpath, $formatter_settings['lineWrapping'] ? '@checked = "checked"' : 'not(@checked)');
$assert_session
->elementExists('xpath', $xpath, $settings_wrapper);
$xpath = '//input[@name = "fields[field_code][settings_edit_form][settings][lineNumbers]" and %s]';
$xpath = sprintf($xpath, $formatter_settings['lineNumbers'] ? '@checked = "checked"' : 'not(@checked)');
$assert_session
->elementExists('xpath', $xpath, $settings_wrapper);
$xpath = '//input[@name = "fields[field_code][settings_edit_form][settings][foldGutter]" and %s]';
$xpath = sprintf($xpath, $formatter_settings['foldGutter'] ? '@checked = "checked"' : 'not(@checked)');
$assert_session
->elementExists('xpath', $xpath, $settings_wrapper);
}