public function FormatterTest::testFormatter in The CodeMirror Editor 8
Test callback.
File
- tests/
src/ FunctionalJavascript/ FormatterTest.php, line 38
Class
- FormatterTest
- Tests the CodeMirror field formatter.
Namespace
Drupal\Tests\codemirror_editor\FunctionalJavascriptCode
public function testFormatter() {
$permissions = [
'administer node fields',
'administer node display',
'create test content',
'edit any test content',
];
$user = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($user);
// Default formatter settings.
$formatter_settings = [
'mode' => 'text/html',
'lineWrapping' => TRUE,
'lineNumbers' => TRUE,
'foldGutter' => FALSE,
];
$this
->drupalGet('node/1');
$this
->assertFormatter($formatter_settings);
$this
->drupalGet('admin/structure/types/manage/test/display');
$this
->assertFormatterSettingsSummary($formatter_settings);
$this
->click('//input[@name = "field_code_settings_edit"]');
$this
->assertFormatterSettingsForm($formatter_settings);
$formatter_settings = [
'mode' => 'application/xml',
'lineWrapping' => FALSE,
'lineNumbers' => FALSE,
'foldGutter' => TRUE,
];
$this
->updateFormatterSettingField('mode', $formatter_settings['mode']);
$this
->updateFormatterSettingField('lineWrapping', $formatter_settings['lineWrapping']);
$this
->updateFormatterSettingField('lineNumbers', $formatter_settings['lineNumbers']);
$this
->updateFormatterSettingField('foldGutter', $formatter_settings['foldGutter']);
$page = $this
->getSession()
->getPage();
$page
->pressButton('field_code_plugin_settings_update');
$this
->assertSession()
->waitForElementVisible('xpath', '//select[@name = "fields[field_code][type]"]');
$page
->pressButton('Save');
$this
->assertSession()
->pageTextContains('Your settings have been saved.');
$this
->assertFormatterSettingsSummary($formatter_settings);
$this
->drupalGet('node/1');
$this
->assertFormatter($formatter_settings);
}