3 namespace Drupal\entity_embed\Tests;
5 use Drupal\system\Tests\Update\UpdatePathTestBase;
8 * Tests the update hooks in entity_embed module.
12 class EntityEmbedUpdateHookTest extends UpdatePathTestBase {
15 * Set database dump files to be used.
17 protected function setDatabaseDumpFiles() {
18 $this->databaseDumpFiles = [
19 DRUPAL_ROOT . '/core/modules/system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
20 __DIR__ . '/../../tests/fixtures/update/entity_embed.update-hook-test.php',
27 protected function setUp() {
29 $button = $this->container
30 ->get('entity_type.manager')
31 ->getDefinition('embed_button');
34 ->get('entity.last_installed_schema.repository')
35 ->setLastInstalledDefinition($button);
41 protected function doSelectionTest() {
42 parent::doSelectionTest();
43 $this->assertRaw('8002 - Updates the default mode settings.');
44 $this->assertRaw('8003 - Updates allowed HTML for all filter format config entities that have an Entity Embed button.');
48 * Tests entity_embed_update_8002().
50 public function todotestPostUpdate() {
52 $mode = $this->container->get('config.factory')
53 ->get('entity_embed.settings')
54 ->get('rendered_entity_mode');
55 $this->assertTrue($mode, 'Render entity mode settings after update is correct.');
59 * Tests entity_embed_update_8003().
61 public function testAllowedHTML() {
62 $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>';
63 $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>';
64 $filter_format = $this->container->get('entity_type.manager')->getStorage('filter_format')->load('full_html');
65 $filter_format->setFilterConfig('filter_html', [
68 'allowed_html' => $allowed_html,
71 $editor = $this->container->get('entity_type.manager')->getStorage('editor')->load('full_html');
72 $button = $this->container->get('entity_type.manager')->getStorage('embed_button')->load('node');
73 $editor->setSettings(['toolbar' => ['rows' => [0 => [0 => ['items' => [0 => $button->id()]]]]]])->save();
75 $filter_format = $this->container->get('entity_type.manager')->getStorage('filter_format')->load('full_html');
76 $filter_html = $filter_format->filters('filter_html');
77 $this->assertEqual($expected_allowed_html, $filter_html->getConfiguration()['settings']['allowed_html'], 'Allowed html is correct');