1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Drupal\entity_embed\Tests; |
4
|
|
|
|
5
|
|
|
use Drupal\system\Tests\Update\UpdatePathTestBase; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Tests the update hooks in entity_embed module. |
9
|
|
|
* |
10
|
|
|
* @group entity_embed |
11
|
|
|
*/ |
12
|
|
|
class EntityEmbedUpdateHookTest extends UpdatePathTestBase { |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Set database dump files to be used. |
16
|
|
|
*/ |
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', |
21
|
|
|
]; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
*/ |
27
|
|
|
protected function setUp() { |
28
|
|
|
parent::setUp(); |
29
|
|
|
$button = $this->container |
30
|
|
|
->get('entity_type.manager') |
31
|
|
|
->getDefinition('embed_button'); |
32
|
|
|
|
33
|
|
|
$this->container |
34
|
|
|
->get('entity.last_installed_schema.repository') |
35
|
|
|
->setLastInstalledDefinition($button); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* {@inheritdoc} |
40
|
|
|
*/ |
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.'); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Tests entity_embed_update_8002(). |
49
|
|
|
*/ |
50
|
|
|
public function todotestPostUpdate() { |
51
|
|
|
$this->runUpdates(); |
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.'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Tests entity_embed_update_8003(). |
60
|
|
|
*/ |
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', [ |
66
|
|
|
'status' => TRUE, |
67
|
|
|
'settings' => [ |
68
|
|
|
'allowed_html' => $allowed_html, |
69
|
|
|
], |
70
|
|
|
])->save(); |
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(); |
74
|
|
|
$this->runUpdates(); |
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'); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
} |
81
|
|
|
|