Interim commit.
[yaffs-website] / web / modules / contrib / video_embed_field / tests / src / FunctionalJavascript / ColorboxFormatterTest.php
1 <?php
2
3 namespace Drupal\Tests\video_embed_field\FunctionalJavascript;
4
5 use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
6 use Drupal\Tests\video_embed_field\Functional\EntityDisplaySetupTrait;
7
8 /**
9  * Test the colorbox formatter.
10  *
11  * @group video_embed_field
12  */
13 class ColorboxFormatterTest extends JavascriptTestBase {
14
15   use EntityDisplaySetupTrait;
16
17   /**
18    * {@inheritdoc}
19    */
20   public static $modules = [
21     'node',
22     'colorbox',
23     'video_embed_field',
24     'colorbox_library_test',
25     'video_embed_field_mock_provider',
26   ];
27
28   /**
29    * How long it takes for colorbox to open.
30    */
31   const COLORBOX_LAUNCH_TIME = 250;
32
33   /**
34    * {@inheritdoc}
35    */
36   protected function setUp() {
37     parent::setUp();
38     $this->setupEntityDisplays();
39   }
40
41   /**
42    * Test the colorbox formatter.
43    */
44   public function testColorboxFormatter() {
45     $this->setDisplayComponentSettings('video_embed_field_colorbox', [
46       'autoplay' => FALSE,
47       'responsive' => TRUE,
48     ]);
49     $node = $this->createVideoNode('https://example.com/mock_video');
50     $this->drupalGet('node/' . $node->id());
51     $this->click('.video-embed-field-launch-modal');
52     $this->getSession()->wait(static::COLORBOX_LAUNCH_TIME);
53     $this->assertSession()->elementExists('css', '#colorbox .video-embed-field-responsive-video');
54     // Make sure the right library files are loaded on the page.
55     $this->assertSession()->elementContains('css', 'style', 'colorbox/styles/default/colorbox_style.css');
56     $this->assertSession()->elementContains('css', 'style', 'video_embed_field/css/video_embed_field.responsive-video.css');
57   }
58
59 }