Tests CKEditor::getJSSettings().
function testGetJSSettings() {
$editor = entity_load('editor', 'filtered_html');
// Default toolbar.
$expected_config = $this
->getDefaultInternalConfig() + array(
'toolbar' => $this
->getDefaultToolbarConfig(),
'contentsCss' => $this
->getDefaultContentsCssConfig(),
'extraPlugins' => '',
'language' => 'en',
'stylesSet' => FALSE,
'drupalExternalPlugins' => array(),
);
$this
->assertIdentical($expected_config, $this->ckeditor
->getJSSettings($editor), 'Generated JS settings are correct for default configuration.');
// Customize the configuration: add button, have two contextually enabled
// buttons, and configure a CKEditor plugin setting.
$this
->enableModules(array(
'ckeditor_test',
));
drupal_container()
->get('plugin.manager.ckeditor.plugin')
->clearCachedDefinitions();
$editor->settings['toolbar']['buttons'][0][] = 'Strike';
$editor->settings['toolbar']['buttons'][1][] = 'Format';
$editor->settings['plugins']['internal']['link_shortcut'] = 'CTRL+K';
$editor
->save();
$expected_config['toolbar'][count($expected_config['toolbar']) - 2]['items'][] = 'Strike';
$expected_config['toolbar'][]['items'][] = 'Format';
$expected_config['toolbar'][] = '/';
$expected_config['format_tags'] = 'p;h4;h5;h6';
$expected_config['extraPlugins'] = 'llama_contextual,llama_contextual_and_button';
$expected_config['drupalExternalPlugins']['llama_contextual'] = file_create_url('core/modules/ckeditor/tests/modules/js/llama_contextual.js');
$expected_config['drupalExternalPlugins']['llama_contextual_and_button'] = file_create_url('core/modules/ckeditor/tests/modules/js/llama_contextual_and_button.js');
$expected_config['contentsCss'][] = file_create_url('core/modules/ckeditor/tests/modules/ckeditor_test.css');
$expected_config['keystrokes'] = array(
array(
1114187,
'link',
),
array(
1114188,
NULL,
),
);
$this
->assertEqual($expected_config, $this->ckeditor
->getJSSettings($editor), 'Generated JS settings are correct for customized configuration.');
// Change the allowed HTML tags; the "format_tags" setting for CKEditor
// should automatically be updated as well.
$format = entity_load('filter_format', 'filtered_html');
$format
->filters('filter_html')->settings['allowed_html'] .= '<pre> <h3>';
$format
->save();
$expected_config['format_tags'] = 'p;h3;h4;h5;h6;pre';
$this
->assertEqual($expected_config, $this->ckeditor
->getJSSettings($editor), 'Generated JS settings are correct for customized configuration.');
}