View source
<?php
namespace Drupal\Tests\video_embed_wysiwyg\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\video_embed_field\Functional\AdminUserTrait;
class TextFormatConfigurationTest extends BrowserTestBase {
use AdminUserTrait;
public static $modules = [
'video_embed_field',
'video_embed_wysiwyg',
'editor',
'ckeditor',
'field_ui',
'node',
'image',
];
protected $formatUrl = 'admin/config/content/formats/manage/plain_text';
protected function setUp() {
parent::setUp();
$this
->drupalLogin($this
->createAdminUser());
$this
->drupalGet($this->formatUrl);
$this
->getSession()
->getPage()
->find('css', '[name="editor[editor]"]')
->setValue('ckeditor');
$this
->getSession()
->getPage()
->find('css', 'input[name="editor_configure"]')
->click();
$this
->submitForm([], t('Save configuration'));
}
public function testFormatConfiguration() {
$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.');
$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.');
}
public function testUrlWeightOrder() {
$this
->drupalGet($this->formatUrl);
$this
->submitForm([
'filters[filter_url][status]' => TRUE,
'filters[filter_html][status]' => FALSE,
'filters[video_embed_wysiwyg][status]' => TRUE,
'editor[settings][toolbar][button_groups]' => '[[{"name":"Group","items":["video_embed"]}]]',
'filters[video_embed_wysiwyg][weight]' => '10',
'filters[filter_url][weight]' => '-10',
], 'Save configuration');
$this
->assertSession()
->pageTextContains('The "Video Embed WYSIWYG" filter must run before the "Convert URLs into links" filter to function correctly.');
$this
->submitForm([
'filters[video_embed_wysiwyg][weight]' => '-10',
'filters[filter_url][weight]' => '10',
], 'Save configuration');
$this
->assertSession()
->pageTextContains('The text format Plain text has been updated.');
}
public function testHtmlFilterWeightOrder() {
$this
->drupalGet($this->formatUrl);
$this
->submitForm([
'filters[filter_html][status]' => TRUE,
'filters[filter_url][status]' => FALSE,
'filters[video_embed_wysiwyg][status]' => TRUE,
'editor[settings][toolbar][button_groups]' => '[[{"name":"Group","items":["video_embed"]}]]',
'filters[video_embed_wysiwyg][weight]' => '-10',
'filters[filter_html][weight]' => '10',
], 'Save configuration');
$this
->assertSession()
->pageTextContains('The "Video Embed WYSIWYG" filter must run after the "Limit allowed HTML tags" filter to function correctly.');
$this
->submitForm([
'filters[video_embed_wysiwyg][weight]' => '10',
'filters[filter_html][weight]' => '-10',
], 'Save configuration');
$this
->assertSession()
->pageTextContains('The text format Plain text has been updated.');
}
public function testDialogDefaultValues() {
$this
->drupalGet($this->formatUrl);
$this
->assertSession()
->pageTextContains('Autoplay');
$this
->assertSession()
->pageTextContains('Responsive Video');
$this
->assertSession()
->pageTextContains('Width');
$this
->assertSession()
->pageTextContains('Height');
$this
->submitForm([
'filters[video_embed_wysiwyg][status]' => TRUE,
'editor[settings][toolbar][button_groups]' => '[[{"name":"Group","items":["video_embed"]}]]',
'editor[settings][plugins][video_embed][defaults][children][width]' => '123',
'editor[settings][plugins][video_embed][defaults][children][height]' => '456',
'editor[settings][plugins][video_embed][defaults][children][responsive]' => FALSE,
'editor[settings][plugins][video_embed][defaults][children][autoplay]' => FALSE,
], t('Save configuration'));
$this
->drupalGet('video-embed-wysiwyg/dialog/plain_text');
$this
->assertSession()
->fieldValueEquals('width', '123');
$this
->assertSession()
->fieldValueEquals('height', '456');
$this
->assertSession()
->fieldValueEquals('autoplay', FALSE);
$this
->assertSession()
->fieldValueEquals('responsive', FALSE);
}
}