e7f0f4435ba1b19013b6cc145a77436bb59980f8
[yaffs-website] / web / core / modules / editor / src / Tests / Update / EditorUpdateTest.php
1 <?php
2
3 namespace Drupal\editor\Tests\Update;
4
5 use Drupal\system\Tests\Update\UpdatePathTestBase;
6
7 /**
8  * Tests Editor module database updates.
9  *
10  * @group editor
11  */
12 class EditorUpdateTest extends UpdatePathTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public function setDatabaseDumpFiles() {
18     $this->databaseDumpFiles = [
19       __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
20       // Simulate an un-synchronized environment.
21       __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.editor-editor_update_8001.php',
22     ];
23   }
24
25   /**
26    * Tests editor_update_8001().
27    *
28    * @see editor_update_8001()
29    */
30   public function testEditorUpdate8001() {
31     /** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */
32     $config_factory = $this->container->get('config.factory');
33
34     $format_basic_html = $config_factory->get('filter.format.basic_html');
35     $editor_basic_html = $config_factory->get('editor.editor.basic_html');
36     $format_full_html = $config_factory->get('filter.format.full_html');
37     $editor_full_html = $config_factory->get('editor.editor.full_html');
38
39     // Checks if the 'basic_html' format and editor statuses differ.
40     $this->assertTrue($format_basic_html->get('status'));
41     $this->assertFalse($editor_basic_html->get('status'));
42     $this->assertNotIdentical($format_basic_html->get('status'), $editor_basic_html->get('status'));
43
44     // Checks if the 'full_html' format and editor statuses differ.
45     $this->assertFalse($format_full_html->get('status'));
46     $this->assertTrue($editor_full_html->get('status'));
47     $this->assertNotIdentical($format_full_html->get('status'), $editor_full_html->get('status'));
48
49
50     // Run updates.
51     $this->runUpdates();
52
53     // Reload text formats and editors.
54     $format_basic_html = $config_factory->get('filter.format.basic_html');
55     $editor_basic_html = $config_factory->get('editor.editor.basic_html');
56     $format_full_html = $config_factory->get('filter.format.full_html');
57     $editor_full_html = $config_factory->get('editor.editor.full_html');
58
59     // Checks if the 'basic_html' format and editor statuses are in sync.
60     $this->assertTrue($format_basic_html->get('status'));
61     $this->assertTrue($editor_basic_html->get('status'));
62     $this->assertIdentical($format_basic_html->get('status'), $editor_basic_html->get('status'));
63
64     // Checks if the 'full_html' format and editor statuses are in sync.
65     $this->assertFalse($format_full_html->get('status'));
66     $this->assertFalse($editor_full_html->get('status'));
67     $this->assertIdentical($format_full_html->get('status'), $editor_full_html->get('status'));
68   }
69
70 }