Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / editor / tests / src / Kernel / EditorFilterIntegrationTest.php
1 <?php
2
3 namespace Drupal\Tests\editor\Kernel;
4
5 use Drupal\editor\Entity\Editor;
6 use Drupal\filter\Entity\FilterFormat;
7 use Drupal\KernelTests\KernelTestBase;
8
9 /**
10  * Tests integration with filter module.
11  *
12  * @group editor
13  */
14 class EditorFilterIntegrationTest extends KernelTestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public static $modules = ['filter', 'editor', 'editor_test'];
20
21   /**
22    * Tests text format removal or disabling.
23    */
24   public function testTextFormatIntegration() {
25     // Create an arbitrary text format.
26     $format = FilterFormat::create([
27       'format' => mb_strtolower($this->randomMachineName()),
28       'name' => $this->randomString(),
29     ]);
30     $format->save();
31
32     // Create a paired editor.
33     Editor::create(['format' => $format->id(), 'editor' => 'unicorn'])->save();
34
35     // Disable the text format.
36     $format->disable()->save();
37
38     // The paired editor should be disabled too.
39     $this->assertFalse(Editor::load($format->id())->status());
40
41     // Re-enable the text format.
42     $format->enable()->save();
43
44     // The paired editor should be enabled too.
45     $this->assertTrue(Editor::load($format->id())->status());
46
47     // Completely remove the text format. Usually this cannot occur via UI, but
48     // can be triggered from API.
49     $format->delete();
50
51     // The paired editor should be removed.
52     $this->assertNull(Editor::load($format->id()));
53   }
54
55 }