function AddedStylesheetsTest::testCkeditorStylesheets

Same name in other branches
  1. 9 core/modules/ckeditor5/tests/src/Functional/AddedStylesheetsTest.php \Drupal\Tests\ckeditor5\Functional\AddedStylesheetsTest::testCkeditorStylesheets()
  2. 11.x core/modules/ckeditor5/tests/src/Functional/AddedStylesheetsTest.php \Drupal\Tests\ckeditor5\Functional\AddedStylesheetsTest::testCkeditorStylesheets()

Test the ckeditor5-stylesheets theme config.

File

core/modules/ckeditor5/tests/src/Functional/AddedStylesheetsTest.php, line 97

Class

AddedStylesheetsTest
Test the ckeditor5-stylesheets theme config property.

Namespace

Drupal\Tests\ckeditor5\Functional

Code

public function testCkeditorStylesheets() : void {
    $assert_session = $this->assertSession();
    
    /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */
    $theme_installer = \Drupal::service('theme_installer');
    $theme_installer->install([
        'test_ckeditor_stylesheets_relative',
        'claro',
    ]);
    $this->config('system.theme')
        ->set('admin', 'claro')
        ->save();
    $this->config('node.settings')
        ->set('use_admin_theme', TRUE)
        ->save();
    $this->drupalGet('node/add/article');
    $assert_session->responseNotContains('test_ckeditor_stylesheets_relative/css/yokotsoko.css');
    // Confirm that the missing ckeditor5-stylesheets configuration can be
    // bypassed.
    $this->drupalGet('admin/config/content/formats/manage/llama');
    $assert_session->pageTextNotContains('ckeditor_stylesheets configured without a corresponding ckeditor5-stylesheets configuration.');
    // Install a theme with ckeditor5-stylesheets configured. Do this manually
    // to confirm `library_info` cache tags are invalidated.
    $this->drupalGet('admin/appearance');
    $this->clickLink('Set Test relative CKEditor stylesheets as default theme');
    // Confirm the stylesheet added via `ckeditor5-stylesheets` is present.
    $this->drupalGet('node/add/article');
    $assert_session->responseContains('test_ckeditor_stylesheets_relative/css/yokotsoko.css');
    // Change the default theme to Stark, and confirm the stylesheet added via
    // `ckeditor5-stylesheets` is no longer present.
    $this->drupalGet('admin/appearance');
    $this->clickLink('Set Stark as default theme');
    $this->drupalGet('node/add/article');
    $assert_session->responseNotContains('test_ckeditor_stylesheets_relative/css/yokotsoko.css');
}

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