You are here

public function VideoEmbedIFrameTest::videoEmbedIframeTestCases in Video Embed Field 8.2

Same name and namespace in other branches
  1. 8 tests/src/Kernel/VideoEmbedIFrameTest.php \Drupal\Tests\video_embed_field\Kernel\VideoEmbedIFrameTest::videoEmbedIframeTestCases()

Test cases for the embed iframe.

Return value

array Video iframe test cases.

File

tests/src/Kernel/VideoEmbedIFrameTest.php, line 18

Class

VideoEmbedIFrameTest
Test that the iframe element works.

Namespace

Drupal\Tests\video_embed_field\Kernel

Code

public function videoEmbedIframeTestCases() {
  return [
    'Default' => [
      [
        '#type' => 'video_embed_iframe',
      ],
      '<iframe></iframe>',
    ],
    'URL' => [
      [
        '#type' => 'video_embed_iframe',
        '#url' => 'https://www.youtube.com/embed/fdbFVWupSsw',
      ],
      '<iframe src="https://www.youtube.com/embed/fdbFVWupSsw"></iframe>',
    ],
    'URL, query' => [
      [
        '#type' => 'video_embed_iframe',
        '#url' => 'https://www.youtube.com/embed/fdbFVWupSsw',
        '#query' => [
          'autoplay' => '1',
        ],
      ],
      '<iframe src="https://www.youtube.com/embed/fdbFVWupSsw?autoplay=1"></iframe>',
    ],
    'URL, query, attributes' => [
      [
        '#type' => 'video_embed_iframe',
        '#url' => 'https://www.youtube.com/embed/fdbFVWupSsw',
        '#query' => [
          'autoplay' => '1',
        ],
        '#attributes' => [
          'width' => '100',
        ],
      ],
      '<iframe width="100" src="https://www.youtube.com/embed/fdbFVWupSsw?autoplay=1"></iframe>',
    ],
    'Query' => [
      [
        '#type' => 'video_embed_iframe',
        '#query' => [
          'autoplay' => '1',
        ],
      ],
      '<iframe></iframe>',
    ],
    'Query, attributes' => [
      [
        '#type' => 'video_embed_iframe',
        '#query' => [
          'autoplay' => '1',
        ],
        '#attributes' => [
          'width' => '100',
        ],
      ],
      '<iframe width="100"></iframe>',
    ],
    'Attributes' => [
      [
        '#type' => 'video_embed_iframe',
        '#attributes' => [
          'width' => '100',
        ],
      ],
      '<iframe width="100"></iframe>',
    ],
    'Fragment' => [
      [
        '#type' => 'video_embed_iframe',
        '#url' => 'https://example.com',
        '#fragment' => 'test fragment',
      ],
      '<iframe src="https://example.com#test fragment"></iframe>',
    ],
    'XSS Testing' => [
      [
        '#type' => 'video_embed_iframe',
        '#attributes' => [
          'xss' => '">',
        ],
        '#query' => [
          'xss' => '">',
        ],
        '#url' => '">',
        '#fragment' => '">',
      ],
      '<iframe xss="&quot;&gt;" src="&quot;&gt;?xss=%22%3E#&quot;&gt;"></iframe>',
    ],
  ];
}