Source of file YouTubeShortCodeHandlerTest.php
Size: 3,127 Bytes - Last Modified: 2021-12-23T10:59:04+00:00
/var/www/docs.ssmods.com/process/src/tests/YouTubeShortCodeHandlerTest.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 | <?php /** * Testing YouTubeShortCodeHandler */ class YouTubeShortCodeHandlerTest extends SapphireTest { protected static $fixture_file = 'YouTubeShortCodeTest.yml'; public function testVideoIdOnly() { $page = $this->objFromFixture('Page', 'VideoIdOnly'); $html = ShortcodeParser::get_active()->parse($page->Content); $this->assertContains('<div class="YouTube">', $html); $expected = '<iframe width="560" height="315" src="https://www.youtube' . '.com/embed/5XQwWATPReA" frameborder="0" allowfullscreen=""' . '></iframe>'; $this->assertContains($expected, $html); } public function testVideoWithCaption() { $page = $this->objFromFixture('Page', 'VideoWithCaption'); $html = ShortcodeParser::get_active()->parse($page->Content); $this->assertContains('<div class="YouTube">', $html); $expected = '<iframe width="560" height="315" src="https://www.youtube' . '.com/embed/5XQwWATPReA" frameborder="0" allowfullscreen=""' . '></iframe>'; $this->assertContains('<p>This is a caption</p>', $html); $this->assertContains($expected, $html); } public function testVideoWithWidth() { $page = $this->objFromFixture('Page', 'VideoWithWidth'); $html = ShortcodeParser::get_active()->parse($page->Content); $this->assertContains('<div class="YouTube">', $html); $expected = '<iframe width="314" height="315" src="https://www.youtube' . '.com/embed/5XQwWATPReA" frameborder="0" allowfullscreen=""' . '></iframe>'; $this->assertContains($expected, $html); } public function testVideoWithHeight() { $page = $this->objFromFixture('Page', 'VideoWithHeight'); $html = ShortcodeParser::get_active()->parse($page->Content); $this->assertContains('<div class="YouTube">', $html); $expected = '<iframe width="560" height="314" src="https://www.youtube' . '.com/embed/5XQwWATPReA" frameborder="0" allowfullscreen=""' . '></iframe>'; $this->assertContains($expected, $html); } public function testVideoWithAll() { $page = $this->objFromFixture('Page', 'VideoWithAll'); $html = ShortcodeParser::get_active()->parse($page->Content); $this->assertContains('<div class="YouTube">', $html); $expected = '<iframe width="314" height="418" src="https://www.youtube' . '.com/embed/5XQwWATPReA" frameborder="0" allowfullscreen=""' . '></iframe>'; $this->assertContains($expected, $html); $this->assertContains('<p>This is a caption</p>', $html); } public function testVideoWithNoID() { $page = $this->objFromFixture('Page', 'VideoWithNoID'); $html = ShortcodeParser::get_active()->parse($page->Content); $this->assertEquals('There should not be a video here ', $html); } public function testVideoWithNoAutoPlay() { $page = $this->objFromFixture('Page', 'VideoWithNoAutoPlay'); $html = ShortcodeParser::get_active()->parse($page->Content); $this->assertContains('<div class="YouTube">', $html); $expected = '<iframe width="560" height="315" src="https://www.youtube.' . 'com/embed/5XQwWATPReA&AutoPlay=1" frameborder="0" allo' . 'wfullscreen="">'; $this->assertContains($expected, $html); } } |