Completed
Push — master ( 980d11...9fc5c3 )
by Gordon
04:41 queued 47s
created

YouTubeShortCodeHandlerTest::testVideoWithWidth()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 8

Duplication

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