3 namespace Drupal\Tests\editor\Kernel;
5 use Drupal\Component\Utility\Unicode;
6 use Drupal\editor\Entity\Editor;
7 use Drupal\filter\Entity\FilterFormat;
8 use Drupal\KernelTests\KernelTestBase;
11 * Tests integration with filter module.
15 class EditorFilterIntegrationTest extends KernelTestBase {
20 public static $modules = ['filter', 'editor', 'editor_test'];
23 * Tests text format removal or disabling.
25 public function testTextFormatIntegration() {
26 // Create an arbitrary text format.
27 $format = FilterFormat::create([
28 'format' => Unicode::strtolower($this->randomMachineName()),
29 'name' => $this->randomString(),
33 // Create a paired editor.
34 Editor::create(['format' => $format->id(), 'editor' => 'unicorn'])->save();
36 // Disable the text format.
37 $format->disable()->save();
39 // The paired editor should be disabled too.
40 $this->assertFalse(Editor::load($format->id())->status());
42 // Re-enable the text format.
43 $format->enable()->save();
45 // The paired editor should be enabled too.
46 $this->assertTrue(Editor::load($format->id())->status());
48 // Completely remove the text format. Usually this cannot occur via UI, but
49 // can be triggered from API.
52 // The paired editor should be removed.
53 $this->assertNull(Editor::load($format->id()));