function CKEditor5TestBase::createNewTextFormat

Same name and namespace in other branches
  1. 11.x core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5TestBase.php \Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5TestBase::createNewTextFormat()
  2. 10 core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5TestBase.php \Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5TestBase::createNewTextFormat()

Create a new text format using CKEditor 5.

1 call to CKEditor5TestBase::createNewTextFormat()
LanguageTest::test in core/modules/ckeditor5/tests/src/FunctionalJavascript/LanguageTest.php
Integration test to ensure that CKEditor 5 UI translations are loaded.

File

core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5TestBase.php, line 57

Class

CKEditor5TestBase
Base class for testing CKEditor 5.

Namespace

Drupal\Tests\ckeditor5\FunctionalJavascript

Code

public function createNewTextFormat($page, $assert_session, $name = 'ckeditor5') {
  $this->drupalGet('admin/config/content/formats/add');
  $page->fillField('name', $name);
  $assert_session->waitForText('Machine name');
  $this->assertNotEmpty($assert_session->waitForText($name));
  $page->checkField('roles[authenticated]');
  if ($name === 'ckeditor5') {
    // Enable the HTML filter, at least one HTML restricting filter is needed
    // before CKEditor 5 can be enabled.
    $this->assertTrue($page->hasUncheckedField('filters[filter_html][status]'));
    $page->checkField('filters[filter_html][status]');
    $assert_session->assertWaitOnAjaxRequest();
    // Add the tags that must be included in the html filter for CKEditor 5.
    $allowed_html_field = $assert_session->fieldExists('filters[filter_html][settings][allowed_html]');
    $allowed_html_field->setValue('<p> <br>');
  }
  $page->selectFieldOption('editor[editor]', $name);
}

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