You are here

public function EntityEmbedUpdateHookTest::testAllowedAttributes in Entity Embed 8

Tests entity_embed_update_8003().

File

tests/src/Functional/EntityEmbedUpdateHookTest.php, line 61

Class

EntityEmbedUpdateHookTest
Tests the update hooks in entity_embed module.

Namespace

Drupal\Tests\entity_embed\Functional

Code

public function testAllowedAttributes() {
  $allowed_html = '<drupal-entity data-entity-type data-entity-uuid data-entity-embed-display data-entity-embed-settings data-align data-caption data-embed-button>';
  $expected_allowed_html = '<drupal-entity data-entity-type data-entity-uuid data-entity-embed-display data-entity-embed-settings data-entity-embed-display-settings data-align data-caption data-embed-button>';
  $filter_format = $this->container
    ->get('entity_type.manager')
    ->getStorage('filter_format')
    ->load('full_html');
  $filter_format
    ->setFilterConfig('filter_html', [
    'status' => TRUE,
    'settings' => [
      'allowed_html' => $allowed_html,
    ],
  ])
    ->save();
  $editor = $this->container
    ->get('entity_type.manager')
    ->getStorage('editor')
    ->load('full_html');
  $button = $this->container
    ->get('entity_type.manager')
    ->getStorage('embed_button')
    ->load('node');
  $editor
    ->setSettings([
    'toolbar' => [
      'rows' => [
        0 => [
          0 => [
            'items' => [
              0 => $button
                ->id(),
            ],
          ],
        ],
      ],
    ],
  ])
    ->save();
  $this
    ->runUpdates();
  $filter_format = $this->container
    ->get('entity_type.manager')
    ->getStorage('filter_format')
    ->load('full_html');
  $filter_html = $filter_format
    ->filters('filter_html');
  $this
    ->assertEquals($expected_allowed_html, $filter_html
    ->getConfiguration()['settings']['allowed_html'], 'Allowed html is correct');
}