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\FFMpegDriver;
|
|
|
|
|
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 FFMpegDriverTest 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 (['avconv', 'ffmpeg'] as $name) {
|
2013-06-25 10:03:20 +02:00
|
|
|
if (null !== $executableFinder->find($name)) {
|
|
|
|
|
$found = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$found) {
|
|
|
|
|
$this->markTestSkipped('Neither ffmpeg or avconv found');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testCreate()
|
|
|
|
|
{
|
|
|
|
|
$logger = $this->getLoggerMock();
|
2022-02-09 14:32:43 +01:00
|
|
|
$ffmpeg = FFMpegDriver::create($logger, []);
|
2013-06-25 10:03:20 +02:00
|
|
|
$this->assertInstanceOf('FFMpeg\Driver\FFMpegDriver', $ffmpeg);
|
|
|
|
|
$this->assertEquals($logger, $ffmpeg->getProcessRunner()->getLogger());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testCreateWithConfig()
|
|
|
|
|
{
|
|
|
|
|
$conf = new Configuration();
|
|
|
|
|
$ffmpeg = FFMpegDriver::create($this->getLoggerMock(), $conf);
|
|
|
|
|
$this->assertEquals($conf, $ffmpeg->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
|
|
|
FFMpegDriver::create($this->getLoggerMock(), ['ffmpeg.binaries' => '/path/to/nowhere']);
|
2013-07-03 14:13:29 +02:00
|
|
|
}
|
2013-06-25 10:03:20 +02:00
|
|
|
}
|