Skip to content
Snippets Groups Projects
Commit 429edf37 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #1898844 by Wim Leers: Fixed No test coverage for hook_editor_js_settings_alter().

parent 00b12b3e
No related branches found
No related tags found
No related merge requests found
......@@ -78,7 +78,7 @@ public function getAttachments(array $format_ids) {
}
// We have all JavaScript settings, allow other modules to alter them.
drupal_alter('editor_js_settings', $settings, $formats);
drupal_alter('editor_js_settings', $settings);
if (empty($attachments['library']) && empty($settings)) {
return array();
......
......@@ -87,9 +87,7 @@ function testManager() {
// Case 3: a text editor available & associated (but associated only with
// the 'Full HTML' text format).
$unicorn_plugin = $this->editorManager->createInstance('unicorn');
$default_editor_settings = $unicorn_plugin->getDefaultSettings();
$editor = entity_create('editor', array(
'name' => 'Full HTML',
'format' => 'full_html',
'editor' => 'unicorn',
));
......@@ -112,6 +110,12 @@ function testManager() {
),
);
$this->assertIdentical($expected, $this->editorManager->getAttachments(array('filtered_html', 'full_html')), 'Correct attachments when one text editor is enabled and retrieving attachments for multiple text formats.');
// Case 4: a text editor available associated, but now with its JS settings
// being altered via hook_editor_js_settings_alter().
state()->set('editor_test_js_settings_alter_enabled', TRUE);
$expected['js'][0]['data']['editor']['formats']['full_html']['editorSettings']['ponyModeEnabled'] = FALSE;
$this->assertIdentical($expected, $this->editorManager->getAttachments(array('filtered_html', 'full_html')), 'hook_editor_js_settings_alter() works correctly.');
}
}
......@@ -25,3 +25,17 @@ function editor_test_editor_default_settings_alter(&$settings, $editor) {
$settings['sparkles'] = FALSE;
}
}
/**
* Implements hook_editor_js_settings_alter().
*/
function editor_test_editor_js_settings_alter(&$settings) {
// Allow tests to enable or disable this alter hook.
if (!state()->get('editor_test_js_settings_alter_enabled', FALSE)) {
return;
}
if (isset($settings['full_html'])) {
$settings['full_html']['editorSettings']['ponyModeEnabled'] = FALSE;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment