Passed
Pull Request — 4 (#10244)
by Steve
06:41
created

EmbedContainerTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 32
c 1
b 0
f 0
dl 0
loc 41
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testGetEmbed() 0 39 1
1
<?php
2
3
namespace SilverStripe\View\Tests\Embed;
4
5
use Embed\Extractor;
6
use SilverStripe\View\Embed\EmbedContainer;
7
8
class EmbedContainerTest extends EmbedUnitTest
9
{
10
    public function testGetEmbed()
11
    {
12
        $url = 'https://www.youtube.com/watch?v=iRXJXaLV0n4';
13
        $title = 'Try to stay SERIOUS -The most popular CAT videos';
14
        $embedContainer = $this->createEmbedContainer(
15
            $url,
16
            $url,
17
            implode('', [
18
                '<html><link rel="alternate" type="application/json+oembed" ',
19
                'href="https://www.youtube.com/oembed?format=json&amp;',
20
                'url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DiRXJXaLV0n4" ',
21
                'title="Try to stay SERIOUS -The most popular CAT videos"></html>'
22
            ]),
23
            json_encode([
24
                'author_url' => 'https://www.youtube.com/channel/UCR2KG2dK1tAkwZZjm7rAiSg',
25
                'thumbnail_width' => 480,
26
                'title' => $title,
27
                'width' => 480,
28
                'provider_name' => 'YouTube',
29
                'author_name' => 'Tiger Funnies',
30
                'height' => 270,
31
                'version' => '1.0',
32
                'type' => 'video',
33
                // phpcs:ignore
34
                'html' => implode('', [
35
                    '<iframe width="480" height="270" src="https://www.youtube.com/embed/iRXJXaLV0n4?feature=oembed" ',
36
                    'frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>'
37
                ]),
38
                'provider_url' => 'https://www.youtube.com/',
39
                'thumbnail_height' => 360,
40
                'thumbnail_url' => 'https://i.ytimg.com/vi/iRXJXaLV0n4/hqdefault.jpg',
41
            ])
42
        );
43
44
        $this->assertEmpty($embedContainer->getOptions());
45
        $embedContainer->setOptions(['foo' => 'bar']);
46
        $extractor = $embedContainer->getExtractor();
47
        $this->assertInstanceOf(Extractor::class, $extractor);
48
        $this->assertSame($title, $extractor->title);
49
    }
50
}
51