Skip to content

Commit

Permalink
adding test for youtube credits running out
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethan Finlay authored and Ethan Finlay committed Dec 14, 2022
1 parent d8b18b5 commit 45160fd
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/VideoScanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,30 @@ public function testCheckInvalidKaltura()
$this->assertEquals(0, $ruleMock->check(), 'No issues when API connection fails.');
$this->assertCount(1, $ruleMock->getErrors(), 'One error found when API connection fails.');
}

public function testCheckNoApiCreditsYoutube()
{
$html = '<embed type="video/webm" src="https://www.youtube.com/watch?v=1xZxxVlu7BM" width="400" height="300">';
$dom = new \DOMDocument('1.0', 'utf-8');
$dom->loadHTML($html);
$options = [
'vimeoApiKey' => 'test',
'youtubeApiKey' => 'test',
'kalturaApiKey' => 'test',
'kalturaUsername' => 'test'
];
$response = VideoScan::NO_API_CREDITS;

$ruleMock = $this->getMockBuilder(VideoScan::class)
->setConstructorArgs([$dom, $options])
->onlyMethods(array('getCaptionData'))
->getMock();

$ruleMock->expects($this->once())
->method('getCaptionData')
->will($this->returnValue($response));

$this->assertEquals(0, $ruleMock->check(), 'No issues when credits run out.');
$this->assertCount(1, $ruleMock->getErrors(), 'One error found when credits run out.');
}
}

0 comments on commit 45160fd

Please sign in to comment.