function CKEditorPluginManagerTest::testCssFiles

Same name and namespace in other branches
  1. 9 core/modules/ckeditor/tests/src/Kernel/CKEditorPluginManagerTest.php \Drupal\Tests\ckeditor\Kernel\CKEditorPluginManagerTest::testCssFiles()

Tests the iframe instance CSS files of plugins.

File

core/modules/ckeditor/tests/src/Kernel/CKEditorPluginManagerTest.php, line 135

Class

CKEditorPluginManagerTest
Tests different ways of enabling CKEditor plugins.

Namespace

Drupal\Tests\ckeditor\Kernel

Code

public function testCssFiles() {
    $this->manager = $this->container
        ->get('plugin.manager.ckeditor.plugin');
    $editor = Editor::load('filtered_html');
    // Case 1: no CKEditor iframe instance CSS file.
    $this->assertIdentical([], $this->manager
        ->getCssFiles($editor), 'No iframe instance CSS file found.');
    // Enable the CKEditor Test module, which has the LlamaCss plugin and
    // clear the editor manager's cache so it is picked up.
    $this->enableModules([
        'ckeditor_test',
    ]);
    $this->manager = $this->container
        ->get('plugin.manager.ckeditor.plugin');
    $settings = $editor->getSettings();
    // LlamaCss: automatically enabled by adding its 'LlamaCSS' button.
    $settings['toolbar']['rows'][0][0]['items'][] = 'LlamaCSS';
    $editor->setSettings($settings);
    $editor->save();
    // Case 2: CKEditor iframe instance CSS file.
    $expected = [
        'llama_css' => [
            drupal_get_path('module', 'ckeditor_test') . '/css/llama.css',
        ],
    ];
    $this->assertIdentical($expected, $this->manager
        ->getCssFiles($editor), 'Iframe instance CSS file found.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.