You are here

public function TextFormatConfigurationTest::testFormatConfiguration in Video Embed Field 8

Same name and namespace in other branches
  1. 8.2 modules/video_embed_wysiwyg/tests/src/Functional/TextFormatConfigurationTest.php \Drupal\Tests\video_embed_wysiwyg\Functional\TextFormatConfigurationTest::testFormatConfiguration()

Test both the input filter and button need to be enabled together.

File

modules/video_embed_wysiwyg/tests/src/Functional/TextFormatConfigurationTest.php, line 55

Class

TextFormatConfigurationTest
Test the format configuration form.

Namespace

Drupal\Tests\video_embed_wysiwyg\Functional

Code

public function testFormatConfiguration() {

  // Save the settings with the filter enabled, but with no button.
  $this
    ->drupalGet($this->formatUrl);
  $this
    ->submitForm([
    'filters[video_embed_wysiwyg][status]' => TRUE,
    'editor[settings][toolbar][button_groups]' => '[]',
  ], t('Save configuration'));
  $this
    ->assertSession()
    ->pageTextContains('To embed videos, make sure you have enabled the "Video Embed WYSIWYG" filter and dragged the video icon into the WYSIWYG toolbar.');
  $this
    ->drupalGet($this->formatUrl);
  $this
    ->submitForm([
    'filters[video_embed_wysiwyg][status]' => FALSE,
    'editor[settings][toolbar][button_groups]' => '[[{"name":"Group","items":["video_embed"]}]]',
  ], t('Save configuration'));
  $this
    ->assertSession()
    ->pageTextContains('To embed videos, make sure you have enabled the "Video Embed WYSIWYG" filter and dragged the video icon into the WYSIWYG toolbar.');
  $this
    ->drupalGet($this->formatUrl);
  $this
    ->submitForm([
    'filters[video_embed_wysiwyg][status]' => TRUE,
    'editor[settings][toolbar][button_groups]' => '[[{"name":"Group","items":["video_embed"]}]]',
  ], t('Save configuration'));
  $this
    ->assertSession()
    ->pageTextContains('The text format Plain text has been updated.');

  // Test the messages aren't triggered if they are in the second row.
  $this
    ->drupalGet($this->formatUrl);
  $this
    ->submitForm([
    'filters[video_embed_wysiwyg][status]' => TRUE,
    'editor[settings][toolbar][button_groups]' => '[[{"name":"Foo","items":["NumberedList"]}],[{"name":"Bar","items":["video_embed"]}]]',
  ], t('Save configuration'));
  $this
    ->assertSession()
    ->pageTextContains('The text format Plain text has been updated.');
}