| 
									
										
										
										
											2013-06-25 10:03:20 +02:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-06 23:38:04 +01:00
										 |  |  | namespace Tests\FFMpeg\Unit; | 
					
						
							| 
									
										
										
										
											2013-06-25 10:03:20 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | use FFMpeg\FFMpegServiceProvider; | 
					
						
							|  |  |  | use Silex\Application; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-14 09:08:50 +01:00
										 |  |  | class FFMpegServiceProviderTest extends TestCase | 
					
						
							| 
									
										
										
										
											2013-06-25 10:03:20 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2021-05-17 03:07:36 +02:00
										 |  |  |     protected function setUp() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (!class_exists('\Application\Silex')) { | 
					
						
							| 
									
										
										
										
											2021-06-23 21:45:48 +02:00
										 |  |  |             $this->markTestSkipped('You MUST have silex/silex installed.'); | 
					
						
							| 
									
										
										
										
											2021-05-17 03:07:36 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-25 10:03:20 +02:00
										 |  |  |     public function testWithConfig() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $app = new Application(); | 
					
						
							|  |  |  |         $app->register(new FFMpegServiceProvider(), array( | 
					
						
							|  |  |  |             'ffmpeg.configuration' => array( | 
					
						
							|  |  |  |                 'ffmpeg.threads'   => 12, | 
					
						
							|  |  |  |                 'ffmpeg.timeout'   => 10666, | 
					
						
							|  |  |  |                 'ffprobe.timeout'  => 4242, | 
					
						
							|  |  |  |             ) | 
					
						
							|  |  |  |         )); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->assertInstanceOf('FFMpeg\FFMpeg', $app['ffmpeg']); | 
					
						
							|  |  |  |         $this->assertSame($app['ffmpeg'], $app['ffmpeg.ffmpeg']); | 
					
						
							|  |  |  |         $this->assertInstanceOf('FFMpeg\FFProbe', $app['ffmpeg.ffprobe']); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->assertEquals(12, $app['ffmpeg']->getFFMpegDriver()->getConfiguration()->get('ffmpeg.threads')); | 
					
						
							|  |  |  |         $this->assertEquals(10666, $app['ffmpeg']->getFFMpegDriver()->getProcessBuilderFactory()->getTimeout()); | 
					
						
							|  |  |  |         $this->assertEquals(4242, $app['ffmpeg.ffprobe']->getFFProbeDriver()->getProcessBuilderFactory()->getTimeout()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function testWithoutConfig() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $app = new Application(); | 
					
						
							|  |  |  |         $app->register(new FFMpegServiceProvider()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->assertInstanceOf('FFMpeg\FFMpeg', $app['ffmpeg']); | 
					
						
							|  |  |  |         $this->assertSame($app['ffmpeg'], $app['ffmpeg.ffmpeg']); | 
					
						
							|  |  |  |         $this->assertInstanceOf('FFMpeg\FFProbe', $app['ffmpeg.ffprobe']); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->assertEquals(4, $app['ffmpeg']->getFFMpegDriver()->getConfiguration()->get('ffmpeg.threads')); | 
					
						
							|  |  |  |         $this->assertEquals(300, $app['ffmpeg']->getFFMpegDriver()->getProcessBuilderFactory()->getTimeout()); | 
					
						
							|  |  |  |         $this->assertEquals(30, $app['ffmpeg.ffprobe']->getFFProbeDriver()->getProcessBuilderFactory()->getTimeout()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function testWithFFMpegBinaryConfig() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $app = new Application(); | 
					
						
							|  |  |  |         $app->register(new FFMpegServiceProvider(), array( | 
					
						
							|  |  |  |             'ffmpeg.configuration' => array( | 
					
						
							|  |  |  |                 'ffmpeg.binaries' => '/path/to/ffmpeg', | 
					
						
							|  |  |  |             ) | 
					
						
							|  |  |  |         )); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-13 00:39:31 +01:00
										 |  |  |         $this->expectException('\FFMpeg\Exception\ExecutableNotFoundException', 'Unable to load FFMpeg'); | 
					
						
							| 
									
										
										
										
											2013-06-25 10:03:20 +02:00
										 |  |  |         $app['ffmpeg']; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function testWithFFMprobeBinaryConfig() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $app = new Application(); | 
					
						
							|  |  |  |         $app->register(new FFMpegServiceProvider(), array( | 
					
						
							|  |  |  |             'ffmpeg.configuration' => array( | 
					
						
							|  |  |  |                 'ffprobe.binaries' => '/path/to/ffprobe', | 
					
						
							|  |  |  |             ) | 
					
						
							|  |  |  |         )); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-13 00:39:31 +01:00
										 |  |  |         $this->expectException('\FFMpeg\Exception\ExecutableNotFoundException', 'Unable to load FFProbe'); | 
					
						
							| 
									
										
										
										
											2013-06-25 10:03:20 +02:00
										 |  |  |         $app['ffmpeg.ffprobe']; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |