|
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
|
|
|
$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&', |
|
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
|
|
|
|