function CKEditorTest::testBuildToolbarJSSetting

Tests CKEditor::buildToolbarJSSetting().

File

drupal/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php, line 119
Definition of \Drupal\ckeditor\Tests\CKEditorTest.

Class

CKEditorTest
Tests for the 'CKEditor' text editor plugin.

Namespace

Drupal\ckeditor\Tests

Code

function testBuildToolbarJSSetting() {
  $editor = entity_load('editor', 'filtered_html');

  // Default toolbar.
  $expected = $this
    ->getDefaultToolbarConfig();
  $this
    ->assertIdentical($expected, $this->ckeditor
    ->buildToolbarJSSetting($editor), '"toolbar" configuration part of JS settings built correctly for default toolbar.');

  // Customize the configuration.
  $editor->settings['toolbar']['buttons'][0][] = 'Strike';
  $editor
    ->save();
  $expected[count($expected) - 2]['items'][] = 'Strike';
  $this
    ->assertIdentical($expected, $this->ckeditor
    ->buildToolbarJSSetting($editor), '"toolbar" configuration part of JS settings built correctly for customized toolbar.');

  // Enable the editor_test module, customize further.
  $this
    ->enableModules(array(
    'ckeditor_test',
  ));
  drupal_container()
    ->get('plugin.manager.ckeditor.plugin')
    ->clearCachedDefinitions();
  $editor->settings['toolbar']['buttons'][0][] = 'Llama';
  $editor
    ->save();
  $expected[count($expected) - 2]['items'][] = 'Llama';
  $this
    ->assertIdentical($expected, $this->ckeditor
    ->buildToolbarJSSetting($editor), '"toolbar" configuration part of JS settings built correctly for customized toolbar with contrib module-provided CKEditor plugin.');
}