@@ -184,4 +184,30 @@ public function testCheckInvalidKaltura()
184184 $ this ->assertEquals (0 , $ ruleMock ->check (), 'No issues when API connection fails. ' );
185185 $ this ->assertCount (1 , $ ruleMock ->getErrors (), 'One error found when API connection fails. ' );
186186 }
187+
188+ public function testCheckNoApiCreditsYoutube ()
189+ {
190+ $ html = '<embed type="video/webm" src="https://www.youtube.com/watch?v=1xZxxVlu7BM" width="400" height="300"> ' ;
191+ $ dom = new \DOMDocument ('1.0 ' , 'utf-8 ' );
192+ $ dom ->loadHTML ($ html );
193+ $ options = [
194+ 'vimeoApiKey ' => 'test ' ,
195+ 'youtubeApiKey ' => 'test ' ,
196+ 'kalturaApiKey ' => 'test ' ,
197+ 'kalturaUsername ' => 'test '
198+ ];
199+ $ response = VideoScan::NO_API_CREDITS ;
200+
201+ $ ruleMock = $ this ->getMockBuilder (VideoScan::class)
202+ ->setConstructorArgs ([$ dom , $ options ])
203+ ->onlyMethods (array ('getCaptionData ' ))
204+ ->getMock ();
205+
206+ $ ruleMock ->expects ($ this ->once ())
207+ ->method ('getCaptionData ' )
208+ ->will ($ this ->returnValue ($ response ));
209+
210+ $ this ->assertEquals (0 , $ ruleMock ->check (), 'No issues when credits run out. ' );
211+ $ this ->assertCount (1 , $ ruleMock ->getErrors (), 'One error found when credits run out. ' );
212+ }
187213}
0 commit comments