|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Testing YouTubeShortCodeHandler |
|
5
|
|
|
*/ |
|
6
|
|
|
class YouTubeShortCodeHandlerTest extends SapphireTest |
|
7
|
|
|
{ |
|
8
|
|
|
protected static $fixture_file = 'YouTubeShortCodeTest.yml'; |
|
9
|
|
|
|
|
10
|
1 |
|
public function testVideoIdOnly() { |
|
11
|
1 |
|
$page = $this->objFromFixture('Page', 'VideoIdOnly'); |
|
12
|
1 |
|
$html = ShortcodeParser::get_active()->parse($page->Content); |
|
13
|
1 |
|
$this->assertContains('<div class="YouTube">', $html); |
|
14
|
|
|
$expected = '<iframe width="560" height="315" src="https://www.youtube' |
|
15
|
|
|
. '.com/embed/5XQwWATPReA" frameborder="0" allowfullscreen=""' |
|
16
|
1 |
|
. '></iframe>'; |
|
17
|
1 |
|
$this->assertContains($expected, $html); |
|
18
|
1 |
|
} |
|
19
|
|
|
|
|
20
|
1 |
View Code Duplication |
public function testVideoWithCaption() { |
|
21
|
1 |
|
$page = $this->objFromFixture('Page', 'VideoWithCaption'); |
|
22
|
1 |
|
$html = ShortcodeParser::get_active()->parse($page->Content); |
|
23
|
1 |
|
$this->assertContains('<div class="YouTube">', $html); |
|
24
|
|
|
$expected = '<iframe width="560" height="315" src="https://www.youtube' |
|
25
|
|
|
. '.com/embed/5XQwWATPReA" frameborder="0" allowfullscreen=""' |
|
26
|
1 |
|
. '></iframe>'; |
|
27
|
1 |
|
$this->assertContains('<p>This is a caption</p>', $html); |
|
28
|
|
|
|
|
29
|
1 |
|
$this->assertContains($expected, $html); |
|
30
|
1 |
|
} |
|
31
|
|
|
|
|
32
|
1 |
|
public function testVideoWithWidth() { |
|
33
|
1 |
|
$page = $this->objFromFixture('Page', 'VideoWithWidth'); |
|
34
|
1 |
|
$html = ShortcodeParser::get_active()->parse($page->Content); |
|
35
|
1 |
|
$this->assertContains('<div class="YouTube">', $html); |
|
36
|
|
|
$expected = '<iframe width="314" height="315" src="https://www.youtube' |
|
37
|
|
|
. '.com/embed/5XQwWATPReA" frameborder="0" allowfullscreen=""' |
|
38
|
1 |
|
. '></iframe>'; |
|
39
|
1 |
|
$this->assertContains($expected, $html); |
|
40
|
1 |
|
} |
|
41
|
|
|
|
|
42
|
1 |
|
public function testVideoWithHeight() { |
|
43
|
1 |
|
$page = $this->objFromFixture('Page', 'VideoWithHeight'); |
|
44
|
1 |
|
$html = ShortcodeParser::get_active()->parse($page->Content); |
|
45
|
1 |
|
$this->assertContains('<div class="YouTube">', $html); |
|
46
|
|
|
$expected = '<iframe width="560" height="314" src="https://www.youtube' |
|
47
|
|
|
. '.com/embed/5XQwWATPReA" frameborder="0" allowfullscreen=""' |
|
48
|
1 |
|
. '></iframe>'; |
|
49
|
1 |
|
$this->assertContains($expected, $html); |
|
50
|
1 |
|
} |
|
51
|
|
|
|
|
52
|
1 |
View Code Duplication |
public function testVideoWithAll() { |
|
53
|
1 |
|
$page = $this->objFromFixture('Page', 'VideoWithAll'); |
|
54
|
1 |
|
$html = ShortcodeParser::get_active()->parse($page->Content); |
|
55
|
1 |
|
$this->assertContains('<div class="YouTube">', $html); |
|
56
|
|
|
$expected = '<iframe width="314" height="418" src="https://www.youtube' |
|
57
|
|
|
. '.com/embed/5XQwWATPReA" frameborder="0" allowfullscreen=""' |
|
58
|
1 |
|
. '></iframe>'; |
|
59
|
1 |
|
$this->assertContains($expected, $html); |
|
60
|
1 |
|
$this->assertContains('<p>This is a caption</p>', $html); |
|
61
|
1 |
|
} |
|
62
|
|
|
|
|
63
|
1 |
|
public function testVideoWithNoID() { |
|
64
|
1 |
|
$page = $this->objFromFixture('Page', 'VideoWithNoID'); |
|
65
|
1 |
|
$html = ShortcodeParser::get_active()->parse($page->Content); |
|
66
|
|
|
|
|
67
|
1 |
|
$this->assertEquals('There should not be a video here ', $html); |
|
68
|
1 |
|
} |
|
69
|
|
|
|
|
70
|
1 |
|
public function testVideoWithNoAutoPlay() { |
|
71
|
1 |
|
$page = $this->objFromFixture('Page', 'VideoWithNoAutoPlay'); |
|
72
|
1 |
|
$html = ShortcodeParser::get_active()->parse($page->Content); |
|
73
|
1 |
|
$this->assertContains('<div class="YouTube">', $html); |
|
74
|
|
|
$expected = '<iframe width="560" height="315" src="https://www.youtube.' |
|
75
|
|
|
. 'com/embed/5XQwWATPReA&AutoPlay=1" frameborder="0" allo' |
|
76
|
1 |
|
. 'wfullscreen="">'; |
|
77
|
1 |
|
$this->assertContains($expected, $html); |
|
78
|
1 |
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|