3 namespace Drupal\Tests\editor\Functional;
6 use Drupal\editor\Entity\Editor;
7 use Drupal\Tests\BrowserTestBase;
10 * Test access to the editor dialog forms.
14 class EditorDialogAccessTest extends BrowserTestBase {
21 public static $modules = ['editor', 'filter', 'ckeditor'];
24 * Test access to the editor image dialog.
26 public function testEditorImageDialogAccess() {
27 $url = Url::fromRoute('editor.image_dialog', ['editor' => 'plain_text']);
28 $session = $this->assertSession();
30 // With no text editor, expect a 404.
31 $this->drupalGet($url);
32 $session->statusCodeEquals(404);
34 // With a text editor but without image upload settings, expect a 200, but
35 // there should not be an input[type=file].
36 $editor = Editor::create([
37 'editor' => 'ckeditor',
38 'format' => 'plain_text',
57 'directory' => 'inline-images',
67 $this->drupalGet($url);
68 $this->assertTrue($this->cssSelect('input[type=text][name="attributes[src]"]'), 'Image uploads disabled: input[type=text][name="attributes[src]"] is present.');
69 $this->assertFalse($this->cssSelect('input[type=file]'), 'Image uploads disabled: input[type=file] is absent.');
70 $session->statusCodeEquals(200);
72 // With image upload settings, expect a 200, and now there should be an
74 $editor->setImageUploadSettings(['status' => TRUE] + $editor->getImageUploadSettings())
77 $this->drupalGet($url);
78 $this->assertFalse($this->cssSelect('input[type=text][name="attributes[src]"]'), 'Image uploads enabled: input[type=text][name="attributes[src]"] is absent.');
79 $this->assertTrue($this->cssSelect('input[type=file]'), 'Image uploads enabled: input[type=file] is present.');
80 $session->statusCodeEquals(200);