function CKEditorLoadingTest::testExternalStylesheets

Tests loading of theme's CKEditor stylesheets defined in the .info file.

File

core/modules/ckeditor/tests/src/Functional/CKEditorLoadingTest.php, line 219

Class

CKEditorLoadingTest
Tests loading of CKEditor.

Namespace

Drupal\Tests\ckeditor\Functional

Code

public function testExternalStylesheets() {
    
    /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */
    $theme_installer = \Drupal::service('theme_installer');
    // Case 1: Install theme which has an absolute external CSS URL.
    $theme_installer->install([
        'test_ckeditor_stylesheets_external',
    ]);
    $this->config('system.theme')
        ->set('default', 'test_ckeditor_stylesheets_external')
        ->save();
    $expected = [
        'https://fonts.googleapis.com/css?family=Open+Sans',
    ];
    $this->assertIdentical($expected, _ckeditor_theme_css('test_ckeditor_stylesheets_external'));
    // Case 2: Install theme which has an external protocol-relative CSS URL.
    $theme_installer->install([
        'test_ckeditor_stylesheets_protocol_relative',
    ]);
    $this->config('system.theme')
        ->set('default', 'test_ckeditor_stylesheets_protocol_relative')
        ->save();
    $expected = [
        '//fonts.googleapis.com/css?family=Open+Sans',
    ];
    $this->assertIdentical($expected, _ckeditor_theme_css('test_ckeditor_stylesheets_protocol_relative'));
    // Case 3: Install theme which has a relative CSS URL.
    $theme_installer->install([
        'test_ckeditor_stylesheets_relative',
    ]);
    $this->config('system.theme')
        ->set('default', 'test_ckeditor_stylesheets_relative')
        ->save();
    $expected = [
        'core/modules/system/tests/themes/test_ckeditor_stylesheets_relative/css/yokotsoko.css',
    ];
    $this->assertIdentical($expected, _ckeditor_theme_css('test_ckeditor_stylesheets_relative'));
}

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