Fix #44 : throw an exception in case of older ffprobe
This commit is contained in:
parent
8bb596a919
commit
3bdb341abb
2 changed files with 26 additions and 1 deletions
|
|
@ -11,8 +11,10 @@
|
||||||
|
|
||||||
namespace FFMpeg\FFProbe;
|
namespace FFMpeg\FFProbe;
|
||||||
|
|
||||||
|
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
|
||||||
use Doctrine\Common\Cache\Cache;
|
use Doctrine\Common\Cache\Cache;
|
||||||
use FFMpeg\Driver\FFProbeDriver;
|
use FFMpeg\Driver\FFProbeDriver;
|
||||||
|
use FFMpeg\Exception\RuntimeException;
|
||||||
|
|
||||||
class OptionsTester implements OptionsTesterInterface
|
class OptionsTester implements OptionsTesterInterface
|
||||||
{
|
{
|
||||||
|
|
@ -55,7 +57,11 @@ class OptionsTester implements OptionsTesterInterface
|
||||||
return $this->cache->fetch($id);
|
return $this->cache->fetch($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = $this->ffprobe->command(array('-help', '-loglevel', 'quiet'));
|
try {
|
||||||
|
$output = $this->ffprobe->command(array('-help', '-loglevel', 'quiet'));
|
||||||
|
} catch (ExecutionFailureException $e) {
|
||||||
|
throw new RuntimeException('Your FFProbe version is too old and does not support `-help` option, please upgrade.', $e->getCode(), $e);
|
||||||
|
}
|
||||||
|
|
||||||
$this->cache->save($id, $output);
|
$this->cache->save($id, $output);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,30 @@
|
||||||
|
|
||||||
namespace FFMpeg\Tests\FFProbe;
|
namespace FFMpeg\Tests\FFProbe;
|
||||||
|
|
||||||
|
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
|
||||||
use FFMpeg\Tests\TestCase;
|
use FFMpeg\Tests\TestCase;
|
||||||
use FFMpeg\FFProbe\OptionsTester;
|
use FFMpeg\FFProbe\OptionsTester;
|
||||||
|
|
||||||
class OptionsTesterTest extends TestCase
|
class OptionsTesterTest extends TestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @expectedException FFMpeg\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage Your FFProbe version is too old and does not support `-help` option, please upgrade.
|
||||||
|
*/
|
||||||
|
public function testHasOptionWithOldFFProbe()
|
||||||
|
{
|
||||||
|
$cache = $this->getCacheMock();
|
||||||
|
|
||||||
|
$ffprobe = $this->getFFProbeDriverMock();
|
||||||
|
$ffprobe->expects($this->once())
|
||||||
|
->method('command')
|
||||||
|
->with(array('-help', '-loglevel', 'quiet'))
|
||||||
|
->will($this->throwException(new ExecutionFailureException('Failed to execute')));
|
||||||
|
|
||||||
|
$tester = new OptionsTester($ffprobe, $cache);
|
||||||
|
$tester->has('-print_format');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider provideOptions
|
* @dataProvider provideOptions
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue