| 
									
										
										
										
											2013-06-25 10:03:20 +02:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace FFMpeg\Tests\Driver; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use Alchemy\BinaryDriver\Configuration; | 
					
						
							|  |  |  | use FFMpeg\Driver\FFProbeDriver; | 
					
						
							|  |  |  | use FFMpeg\Tests\TestCase; | 
					
						
							|  |  |  | use Symfony\Component\Process\ExecutableFinder; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class FFProbeDriverTest extends TestCase | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     public function setUp() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $executableFinder = new ExecutableFinder(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $found = false; | 
					
						
							|  |  |  |         foreach (array('avprobe', 'ffprobe') as $name) { | 
					
						
							|  |  |  |             if (null !== $executableFinder->find($name)) { | 
					
						
							|  |  |  |                 $found = true; | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (!$found) { | 
					
						
							|  |  |  |             $this->markTestSkipped('Neither ffprobe or avprobe found'); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function testCreate() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $logger = $this->getLoggerMock(); | 
					
						
							|  |  |  |         $ffprobe = FFProbeDriver::create(array(), $logger); | 
					
						
							|  |  |  |         $this->assertInstanceOf('FFMpeg\Driver\FFProbeDriver', $ffprobe); | 
					
						
							|  |  |  |         $this->assertEquals($logger, $ffprobe->getProcessRunner()->getLogger()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function testCreateWithConfig() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $conf = new Configuration(); | 
					
						
							|  |  |  |         $ffprobe = FFProbeDriver::create($conf, $this->getLoggerMock()); | 
					
						
							|  |  |  |         $this->assertEquals($conf, $ffprobe->getConfiguration()); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-07-03 14:13:29 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @expectedException FFMpeg\Exception\ExecutableNotFoundException | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function testCreateFailureThrowsAnException() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         FFProbeDriver::create(array('ffprobe.binaries' => '/path/to/nowhere')); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-06-25 10:03:20 +02:00
										 |  |  | } |