You are here

public function EmbedDialogTest::setUp in Video Embed Field 8

Same name and namespace in other branches
  1. 8.2 modules/video_embed_wysiwyg/tests/src/FunctionalJavascript/EmbedDialogTest.php \Drupal\Tests\video_embed_wysiwyg\FunctionalJavascript\EmbedDialogTest::setUp()

Overrides BrowserTestBase::setUp

File

modules/video_embed_wysiwyg/tests/src/FunctionalJavascript/EmbedDialogTest.php, line 42

Class

EmbedDialogTest
Test the dialog form.

Namespace

Drupal\Tests\video_embed_wysiwyg\FunctionalJavascript

Code

public function setUp() {
  parent::setUp();
  $this->adminUser = $this
    ->drupalCreateUser(array_keys($this->container
    ->get('user.permissions')
    ->getPermissions()));
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->createContentType([
    'type' => 'page',
  ]);
  \Drupal::configFactory()
    ->getEditable('image.settings')
    ->set('suppress_itok_output', TRUE)
    ->save();

  // Assert access is denied without enabling the filter.
  $this
    ->drupalGet('video-embed-wysiwyg/dialog/plain_text');
  $this
    ->assertSession()
    ->pageTextContains('Access denied');

  // Enable the filter.
  $this
    ->drupalGet('admin/config/content/formats/manage/plain_text');
  $this
    ->find('[name="editor[editor]"]')
    ->setValue('ckeditor');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->getSession()
    ->getDriver()
    ->executeScript("jQuery('.form-item-editor-settings-toolbar-button-groups').show();");
  $this
    ->submitForm([
    'filters[video_embed_wysiwyg][status]' => TRUE,
    'filters[filter_html_escape][status]' => FALSE,
    'editor[settings][toolbar][button_groups]' => '[[{"name":"Group","items":["video_embed","Source"]}]]',
  ], t('Save configuration'));

  // Visit the modal again.
  $this
    ->drupalGet('video-embed-wysiwyg/dialog/plain_text');
  $this
    ->assertSession()
    ->pageTextNotContains('Access denied');
}