You are here

public function UiDialogTest::testFilterHtmlEnable in Editor Advanced Image 8

Same name and namespace in other branches
  1. 8.2 tests/src/FunctionalJavascript/UiDialogTest.php \Drupal\Tests\editor_advanced_image\FunctionalJavascript\UiDialogTest::testFilterHtmlEnable()

Test the appearance of EIA attributes when no filters enabled/partial.

File

tests/src/FunctionalJavascript/UiDialogTest.php, line 170

Class

UiDialogTest
Tests event info pages and links.

Namespace

Drupal\Tests\editor_advanced_image\FunctionalJavascript

Code

public function testFilterHtmlEnable() {

  // Enable the filter_html filter: only a few img attributes.
  $this->editorFilterFormat
    ->setFilterConfig('filter_html', [
    'status' => 1,
    'settings' => [
      'allowed_html' => '<img src alt data-entity-type data-entity-uuid data-align data-caption>',
    ],
  ]);
  $this->editorFilterFormat
    ->save();
  $this
    ->testImageBaseDialogWorks();
  $this
    ->assertElementNotPresent('.ui-dialog .form-item-attributes-title');
  $this
    ->assertElementNotPresent('.ui-dialog .form-item-attributes-class');
  $this
    ->assertElementNotPresent('.ui-dialog .form-item-attributes-id');

  // Enable the filter_html filter: only a title img attributes.
  $this->editorFilterFormat
    ->setFilterConfig('filter_html', [
    'status' => 1,
    'settings' => [
      'allowed_html' => '<img src alt data-entity-type data-entity-uuid data-align data-caption title>',
    ],
  ]);
  $this->editorFilterFormat
    ->save();
  $this
    ->testImageBaseDialogWorks();
  $this
    ->assertElementPresent('.ui-dialog .form-item-attributes-title');
  $this
    ->assertElementNotPresent('.ui-dialog .form-item-attributes-class');
  $this
    ->assertElementNotPresent('.ui-dialog .form-item-attributes-id');

  // Enable the filter_html filter: only a class img attributes.
  $this->editorFilterFormat
    ->setFilterConfig('filter_html', [
    'status' => 1,
    'settings' => [
      'allowed_html' => '<img src alt data-entity-type data-entity-uuid data-align data-caption class>',
    ],
  ]);
  $this->editorFilterFormat
    ->save();
  $this
    ->testImageBaseDialogWorks();
  $this
    ->assertElementNotPresent('.ui-dialog .form-item-attributes-title');
  $this
    ->assertElementPresent('.ui-dialog .form-item-attributes-class');
  $this
    ->assertElementNotPresent('.ui-dialog .form-item-attributes-id');

  // Enable the filter_html filter: only a id img attributes.
  $this->editorFilterFormat
    ->setFilterConfig('filter_html', [
    'status' => 1,
    'settings' => [
      'allowed_html' => '<img src alt data-entity-type data-entity-uuid data-align data-caption id>',
    ],
  ]);
  $this->editorFilterFormat
    ->save();
  $this
    ->testImageBaseDialogWorks();
  $this
    ->assertElementNotPresent('.ui-dialog .form-item-attributes-title');
  $this
    ->assertElementNotPresent('.ui-dialog .form-item-attributes-class');
  $this
    ->assertElementPresent('.ui-dialog .form-item-attributes-id');

  // Enable the filter_html filter: only a id, class, title img attributes.
  $this->editorFilterFormat
    ->setFilterConfig('filter_html', [
    'status' => 1,
    'settings' => [
      'allowed_html' => '<img src alt data-entity-type data-entity-uuid data-align data-caption class id title>',
    ],
  ]);
  $this->editorFilterFormat
    ->save();
  $this
    ->testImageBaseDialogWorks();
  $this
    ->assertElementPresent('.ui-dialog .form-item-attributes-title');
  $this
    ->assertElementPresent('.ui-dialog .form-item-attributes-class');
  $this
    ->assertElementPresent('.ui-dialog .form-item-attributes-id');
}