3 namespace Drupal\Tests\editor\Kernel;
5 use Drupal\editor\Entity\Editor;
6 use Drupal\filter\Entity\FilterFormat;
7 use Drupal\KernelTests\KernelTestBase;
10 * Tests integration with filter module.
14 class EditorFilterIntegrationTest extends KernelTestBase {
19 public static $modules = ['filter', 'editor', 'editor_test'];
22 * Tests text format removal or disabling.
24 public function testTextFormatIntegration() {
25 // Create an arbitrary text format.
26 $format = FilterFormat::create([
27 'format' => mb_strtolower($this->randomMachineName()),
28 'name' => $this->randomString(),
32 // Create a paired editor.
33 Editor::create(['format' => $format->id(), 'editor' => 'unicorn'])->save();
35 // Disable the text format.
36 $format->disable()->save();
38 // The paired editor should be disabled too.
39 $this->assertFalse(Editor::load($format->id())->status());
41 // Re-enable the text format.
42 $format->enable()->save();
44 // The paired editor should be enabled too.
45 $this->assertTrue(Editor::load($format->id())->status());
47 // Completely remove the text format. Usually this cannot occur via UI, but
48 // can be triggered from API.
51 // The paired editor should be removed.
52 $this->assertNull(Editor::load($format->id()));