class SourceEditingTestBase
Same name and namespace in other branches
- 11.x core/modules/ckeditor5/tests/src/FunctionalJavascript/SourceEditingTestBase.php \Drupal\Tests\ckeditor5\FunctionalJavascript\SourceEditingTestBase
@internal
Hierarchy
- class \Drupal\Tests\ckeditor5\FunctionalJavascript\SourceEditingTestBase
Expanded class hierarchy of SourceEditingTestBase
File
-
core/
modules/ ckeditor5/ tests/ src/ FunctionalJavascript/ SourceEditingTestBase.php, line 18
Namespace
Drupal\Tests\ckeditor5\FunctionalJavascriptView source
abstract class SourceEditingTestBase extends CKEditor5TestBase {
use CKEditor5TestTrait;
/**
* The user to use during testing.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
/**
* A host entity with a body field whose text to edit with CKEditor 5.
*
* @var \Drupal\node\NodeInterface
*/
protected $host;
/**
* {@inheritdoc}
*/
protected static $modules = [
'ckeditor5',
'node',
'text',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
FilterFormat::create([
'format' => 'test_format',
'name' => 'Test format',
'filters' => [
'filter_html' => [
'status' => TRUE,
'settings' => [
'allowed_html' => '<div class> <p> <br> <a href> <ol> <ul> <li>',
],
],
'filter_align' => [
'status' => TRUE,
],
'filter_caption' => [
'status' => TRUE,
],
],
])->save();
Editor::create([
'editor' => 'ckeditor5',
'format' => 'test_format',
'settings' => [
'toolbar' => [
'items' => [
'sourceEditing',
'link',
'bulletedList',
'numberedList',
],
],
'plugins' => [
'ckeditor5_sourceEditing' => [
'allowed_tags' => [
'<div class>',
],
],
'ckeditor5_list' => [
'properties' => [
'reversed' => FALSE,
'startIndex' => FALSE,
],
'multiBlock' => TRUE,
],
],
],
'image_upload' => [
'status' => FALSE,
],
])->save();
$this->assertSame([], array_map(function (ConstraintViolation $v) {
return (string) $v->getMessage();
}, iterator_to_array(CKEditor5::validatePair(Editor::load('test_format'), FilterFormat::load('test_format')))));
$this->adminUser = $this->drupalCreateUser([
'use text format test_format',
'bypass node access',
]);
// Create a sample host entity to test CKEditor 5.
$this->host = $this->createNode([
'type' => 'page',
'title' => 'Animals with strange names',
'body' => [
'value' => '',
'format' => 'test_format',
],
]);
$this->host
->save();
$this->drupalLogin($this->adminUser);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
SourceEditingTestBase::$adminUser | protected | property | The user to use during testing. |
SourceEditingTestBase::$defaultTheme | protected | property | The theme to install as the default for testing. |
SourceEditingTestBase::$host | protected | property | A host entity with a body field whose text to edit with CKEditor 5. |
SourceEditingTestBase::$modules | protected static | property | Modules to install. |
SourceEditingTestBase::setUp | protected | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.