
| Current Path : /var/www/html/pallets_old/web/core/modules/ckeditor5/tests/src/Functional/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/pallets_old/web/core/modules/ckeditor5/tests/src/Functional/AddedStylesheetsTest.php |
<?php
namespace Drupal\Tests\ckeditor5\Functional;
use Drupal\ckeditor5\Plugin\Editor\CKEditor5;
use Drupal\editor\Entity\Editor;
use Drupal\filter\Entity\FilterFormat;
use Drupal\Tests\BrowserTestBase;
use Drupal\user\RoleInterface;
use Symfony\Component\Validator\ConstraintViolation;
/**
* Test the ckeditor5-stylesheets theme config property.
*
* @group ckeditor5
*/
class AddedStylesheetsTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'node',
'ckeditor5',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$filtered_html_format = FilterFormat::create([
'format' => 'llama',
'name' => 'Llama',
'filters' => [],
'roles' => [RoleInterface::AUTHENTICATED_ID],
]);
$filtered_html_format->save();
$this->editor = Editor::create([
'format' => 'llama',
'editor' => 'ckeditor5',
'settings' => [
'toolbar' => [
'items' => [],
],
],
]);
$this->editor->save();
$this->assertSame([], array_map(
function (ConstraintViolation $v) {
return (string) $v->getMessage();
},
iterator_to_array(CKEditor5::validatePair($this->editor, $filtered_html_format))
));
// Create node type.
$this->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
$this->adminUser = $this->drupalCreateUser([
'create article content',
'use text format llama',
'administer themes',
'view the administration theme',
]);
$this->drupalLogin($this->adminUser);
}
/**
* Test the ckeditor5-stylesheets theme config.
*/
public function testCkeditorStylesheets() {
$assert_session = $this->assertSession();
/** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */
$theme_installer = \Drupal::service('theme_installer');
$theme_installer->install(['test_ckeditor_stylesheets_relative', 'seven']);
$this->config('system.theme')->set('admin', 'seven')->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');
// 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');
}
}