3 namespace Drupal\Tests\video_embed_field\Kernel;
6 * Test that the iframe element works.
8 * @group video_embed_field
10 class VideoEmbedIFrameTest extends KernelTestBase {
13 * Test cases for the embed iframe.
16 * Video iframe test cases.
18 public function videoEmbedIframeTestCases() {
22 '#type' => 'video_embed_iframe',
28 '#type' => 'video_embed_iframe',
29 '#url' => 'https://www.youtube.com/embed/fdbFVWupSsw',
31 '<iframe src="https://www.youtube.com/embed/fdbFVWupSsw"></iframe>',
35 '#type' => 'video_embed_iframe',
36 '#url' => 'https://www.youtube.com/embed/fdbFVWupSsw',
37 '#query' => ['autoplay' => '1'],
39 '<iframe src="https://www.youtube.com/embed/fdbFVWupSsw?autoplay=1"></iframe>',
41 'URL, query, attributes' => [
43 '#type' => 'video_embed_iframe',
44 '#url' => 'https://www.youtube.com/embed/fdbFVWupSsw',
45 '#query' => ['autoplay' => '1'],
50 '<iframe width="100" src="https://www.youtube.com/embed/fdbFVWupSsw?autoplay=1"></iframe>',
54 '#type' => 'video_embed_iframe',
55 '#query' => ['autoplay' => '1'],
59 'Query, attributes' => [
61 '#type' => 'video_embed_iframe',
62 '#query' => ['autoplay' => '1'],
67 '<iframe width="100"></iframe>',
71 '#type' => 'video_embed_iframe',
76 '<iframe width="100"></iframe>',
80 '#type' => 'video_embed_iframe',
81 '#url' => 'https://example.com',
82 '#fragment' => 'test fragment',
84 '<iframe src="https://example.com#test fragment"></iframe>',
88 '#type' => 'video_embed_iframe',
92 '#query' => ['xss' => '">'],
96 '<iframe xss="">" src="">?xss=%22%3E#">"></iframe>',
102 * Test the video embed iframe renders correctly.
104 * @dataProvider videoEmbedIframeTestCases
106 public function testVideoEmbedIframe($renderable, $markup) {
107 $this->assertEquals($markup, trim($this->container->get('renderer')->renderRoot($renderable)));