public function ConfigurationUiTest::testValidationWhenAdding in Entity Embed 8
Test integration with Filter and Text Editor form validation.
@dataProvider providerTestValidations @dataProvider providerTestValidationWhenAdding
Parameters
bool $filter_html_status: Whether to enable filter_html.
bool $entity_embed_status: Whether to enabled entity_embed.
string|false $allowed_html: The allowed HTML to set. Set to 'default' to test 'drupal-entity' is missing or FALSE to leave the properly alone.
string $expected_error_message: The error message that should display.
File
- tests/
src/ FunctionalJavascript/ ConfigurationUiTest.php, line 90
Class
- ConfigurationUiTest
- Tests text format & text editor configuration UI validation.
Namespace
Drupal\Tests\entity_embed\FunctionalJavascriptCode
public function testValidationWhenAdding($filter_html_status, $entity_embed_status, $allowed_html, $expected_error_message) {
$this
->drupalGet('admin/config/content/formats/add');
// Enable the `filter_html` and `entity_embed` filters, and select CKEditor
// as the text editor.
$page = $this
->getSession()
->getPage();
$page
->fillField('name', 'Test Format');
$this
->showHiddenFields();
$page
->findField('format')
->setValue('test_format');
if ($filter_html_status) {
$page
->checkField('filters[filter_html][status]');
}
if ($entity_embed_status) {
$page
->checkField('filters[entity_embed][status]');
}
$page
->selectFieldOption('editor[editor]', 'ckeditor');
// Verify that after dragging the Entity Embed CKEditor plugin button into
// the active toolbar, the <drupal-entity> tag is allowed, as well as some
// attributes.
$item = 'li[data-drupal-ckeditor-button-name="test_media_entity_embed"]';
$from = "ul {$item}";
$target = 'ul.ckeditor-toolbar-group-buttons';
$this
->assertSession()
->waitForElementVisible('css', $target);
$this
->sortableTo($item, $from, $target);
if ($allowed_html == 'default' && $entity_embed_status) {
// Unfortunately the <drupal-entity> tag is not yet allowed due to
// https://www.drupal.org/project/drupal/issues/2763075.
$allowed_html = $this
->assertSession()
->fieldExists('filters[filter_html][settings][allowed_html]')
->getValue();
$this
->assertStringNotContainsString('drupal-entity', $allowed_html);
}
elseif (!empty($allowed_html)) {
$page
->fillField('filters[filter_html][settings][allowed_html]', $allowed_html);
}
$this
->assertSession()
->buttonExists('Save configuration')
->press();
if ($expected_error_message) {
$this
->assertSession()
->pageTextNotContains('Added text format Test Format.');
$this
->assertSession()
->pageTextContains($expected_error_message);
}
else {
$this
->assertSession()
->pageTextContains('Added text format Test Format.');
}
}