Passed
Pull Request — 4 (#10244)
by Steve
08:11
created

EmbedContainerTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

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

1 Method

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