class CKEditor5StylesheetsTest

Same name and namespace in other branches
  1. 11.x core/modules/ckeditor5/tests/src/Kernel/CKEditor5StylesheetsTest.php \Drupal\Tests\ckeditor5\Kernel\CKEditor5StylesheetsTest

Test the ckeditor5-stylesheets theme config property.

@group ckeditor5

Hierarchy

Expanded class hierarchy of CKEditor5StylesheetsTest

File

core/modules/ckeditor5/tests/src/Kernel/CKEditor5StylesheetsTest.php, line 14

Namespace

Drupal\Tests\ckeditor5\Kernel
View source
class CKEditor5StylesheetsTest extends KernelTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'system',
    'user',
    'ckeditor5',
    'editor',
    'filter',
  ];
  
  /**
   * Tests loading of theme's CKEditor 5 stylesheets defined in the .info file.
   *
   * @param string $theme
   *   The machine name of the theme.
   * @param array $expected
   *   The expected CKEditor 5 CSS paths from the theme.
   *
   * @dataProvider externalStylesheetsProvider
   */
  public function testExternalStylesheets($theme, $expected) {
    \Drupal::service('theme_installer')->install([
      $theme,
    ]);
    $this->config('system.theme')
      ->set('default', $theme)
      ->save();
    $this->assertSame($expected, _ckeditor5_theme_css($theme));
  }
  
  /**
   * Provides test cases for external stylesheets.
   *
   * @return array
   *   An array of test cases.
   */
  public function externalStylesheetsProvider() {
    return [
      'Install theme which has an absolute external CSS URL' => [
        'test_ckeditor_stylesheets_external',
        [
          'https://fonts.googleapis.com/css?family=Open+Sans',
        ],
      ],
      'Install theme which has an external protocol-relative CSS URL' => [
        'test_ckeditor_stylesheets_protocol_relative',
        [
          '//fonts.googleapis.com/css?family=Open+Sans',
        ],
      ],
      'Install theme which has a relative CSS URL' => [
        'test_ckeditor_stylesheets_relative',
        [
          '/core/modules/system/tests/themes/test_ckeditor_stylesheets_relative/css/yokotsoko.css',
        ],
      ],
      'Install theme which has a Drupal root CSS URL' => [
        'test_ckeditor_stylesheets_drupal_root',
        [
          '/core/modules/system/tests/themes/test_ckeditor_stylesheets_drupal_root/css/yokotsoko.css',
        ],
      ],
    ];
  }

}

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