2013-06-25 10:03:20 +02:00
|
|
|
<?php
|
|
|
|
|
|
2016-03-06 23:38:04 +01:00
|
|
|
namespace Tests\FFMpeg\Unit\Driver;
|
2013-06-25 10:03:20 +02:00
|
|
|
|
|
|
|
|
use Alchemy\BinaryDriver\Configuration;
|
|
|
|
|
use FFMpeg\Driver\FFProbeDriver;
|
|
|
|
|
use Symfony\Component\Process\ExecutableFinder;
|
2022-02-09 14:32:43 +01:00
|
|
|
use Tests\FFMpeg\Unit\TestCase;
|
2013-06-25 10:03:20 +02:00
|
|
|
|
|
|
|
|
class FFProbeDriverTest extends TestCase
|
|
|
|
|
{
|
2022-02-09 14:32:43 +01:00
|
|
|
public function setUp(): void
|
2013-06-25 10:03:20 +02:00
|
|
|
{
|
|
|
|
|
$executableFinder = new ExecutableFinder();
|
|
|
|
|
|
|
|
|
|
$found = false;
|
2022-02-09 14:32:43 +01:00
|
|
|
foreach (['avprobe', 'ffprobe'] as $name) {
|
2013-06-25 10:03:20 +02:00
|
|
|
if (null !== $executableFinder->find($name)) {
|
|
|
|
|
$found = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$found) {
|
|
|
|
|
$this->markTestSkipped('Neither ffprobe or avprobe found');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testCreate()
|
|
|
|
|
{
|
|
|
|
|
$logger = $this->getLoggerMock();
|
2022-02-09 14:32:43 +01:00
|
|
|
$ffprobe = FFProbeDriver::create([], $logger);
|
2013-06-25 10:03:20 +02:00
|
|
|
$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
|
|
|
|
|
|
|
|
public function testCreateFailureThrowsAnException()
|
|
|
|
|
{
|
2020-02-13 00:39:31 +01:00
|
|
|
$this->expectException('\FFMpeg\Exception\ExecutableNotFoundException');
|
2022-02-09 14:32:43 +01:00
|
|
|
FFProbeDriver::create(['ffprobe.binaries' => '/path/to/nowhere']);
|
2013-07-03 14:13:29 +02:00
|
|
|
}
|
2013-06-25 10:03:20 +02:00
|
|
|
}
|