X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fvideo_embed_field%2Fmodules%2Fvideo_embed_wysiwyg%2Ftests%2Fsrc%2FFunctional%2FTextFormatConfigurationTest.php;fp=web%2Fmodules%2Fcontrib%2Fvideo_embed_field%2Fmodules%2Fvideo_embed_wysiwyg%2Ftests%2Fsrc%2FFunctional%2FTextFormatConfigurationTest.php;h=3f565f22cfd611c175397a98ac0e9c400a0e1927;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/video_embed_field/modules/video_embed_wysiwyg/tests/src/Functional/TextFormatConfigurationTest.php b/web/modules/contrib/video_embed_field/modules/video_embed_wysiwyg/tests/src/Functional/TextFormatConfigurationTest.php new file mode 100644 index 000000000..3f565f22c --- /dev/null +++ b/web/modules/contrib/video_embed_field/modules/video_embed_wysiwyg/tests/src/Functional/TextFormatConfigurationTest.php @@ -0,0 +1,167 @@ +drupalLogin($this->createAdminUser()); + $this->drupalGet($this->formatUrl); + + // Setup the filter to have an editor. + $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')); + } + + /** + * Test both the input filter and button need to be enabled together. + */ + 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.'); + } + + /** + * Test the URL filter weight is in the correct order. + */ + public function testUrlWeightOrder() { + $this->drupalGet($this->formatUrl); + $this->submitForm([ + // Enable the URL filter and the WYSIWYG embed. + '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"]}]]', + // Setup the weights so the URL filter runs first. + '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.'); + + // Submit the form with the weights reversed. + $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.'); + } + + /** + * Test the URL filter weight is in the correct order. + */ + public function testHtmlFilterWeightOrder() { + $this->drupalGet($this->formatUrl); + $this->submitForm([ + // Enable the URL filter and the WYSIWYG embed. + '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"]}]]', + // Run WYSWIYG first then the HTML filter. + '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.'); + + // Submit the form with the weights reversed. + $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.'); + } + + /** + * Test the dialog defaults can be set and work correctly. + */ + public function testDialogDefaultValues() { + $this->drupalGet($this->formatUrl); + + // Assert all the form fields that appear on the modal, appear as + // configurable defaults. + $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')); + + // Ensure the configured defaults show up on the modal window. + $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); + } + +}