You are here

public function CKEditorPluginManagerTest::testCssFiles in Drupal 9

Same name and namespace in other branches
  1. 8 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 141

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
    ->assertSame([], $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' => [
      $this
        ->getModulePath('ckeditor_test') . '/css/llama.css',
    ],
  ];
  $this
    ->assertSame($expected, $this->manager
    ->getCssFiles($editor), 'Iframe instance CSS file found.');
}