Merge branch 'master' into pr/789

This commit is contained in:
Pascal Baljet 2021-12-20 13:52:02 +01:00
commit d3a0dde89a
20 changed files with 177 additions and 169 deletions

View file

@ -11,10 +11,10 @@ class AudioConcatenationTest extends FunctionalTestCase
{
$ffmpeg = $this->getFFMpeg();
$files = [
$files = array(
realpath(__DIR__ . '/../files/Jahzzar_-_05_-_Siesta.mp3'),
realpath(__DIR__ . '/../files/02_-_Favorite_Secrets.mp3'),
];
);
$audio = $ffmpeg->open(reset($files));

View file

@ -7,6 +7,13 @@ use Silex\Application;
class FFMpegServiceProviderTest extends TestCase
{
protected function setUp()
{
if (!class_exists('\Application\Silex')) {
$this->markTestSkipped('You MUST have silex/silex installed.');
}
}
public function testWithConfig()
{
$app = new Application();

View file

@ -2,8 +2,9 @@
namespace Tests\FFMpeg\Unit\FFProbe;
use Tests\FFMpeg\Unit\TestCase;
use FFMpeg\FFProbe\OptionsTester;
use Symfony\Component\Cache\CacheItem;
use Tests\FFMpeg\Unit\TestCase;
class OptionsTesterTest extends TestCase
{
@ -36,11 +37,12 @@ class OptionsTesterTest extends TestCase
{
$cache = $this->getCacheMock();
$cache->expects($this->never())
->method('fetch');
$cache->expects($this->exactly(2))
->method('getItem')
->will($this->returnValue(new CacheItem));
$cache->expects($this->exactly(2))
->method('contains')
->method('hasItem')
->will($this->returnValue(false));
$cache->expects($this->exactly(2))
@ -73,16 +75,22 @@ class OptionsTesterTest extends TestCase
{
$cache = $this->getCacheMock();
$cache->expects($this->once())
->method('fetch')
->will($this->returnValue($data));
$cacheItem = new CacheItem;
$cacheItem->set($data);
$cache->expects($this->exactly(2))
->method('contains')
->method('getItem')
->willReturnOnConsecutiveCalls(
$this->returnValue($cacheItem),
$this->returnValue(new CacheItem)
);
$cache->expects($this->exactly(2))
->method('hasItem')
->willReturnOnConsecutiveCalls(
$this->returnValue(false),
$this->returnValue(true));
$this->returnValue(true)
);
$cache->expects($this->once())
->method('save');
@ -101,14 +109,17 @@ class OptionsTesterTest extends TestCase
{
$cache = $this->getCacheMock();
$cache->expects($this->once())
->method('fetch')
->with('option-' . $optionName)
->will($this->returnValue($isPresent));
$cacheItem = new CacheItem();
$cacheItem->set($isPresent);
$cache->expects($this->once())
->method('contains')
->with('option-' . $optionName)
->method('getItem')
->with(md5('option-' . $optionName))
->will($this->returnValue($cacheItem));
$cache->expects($this->once())
->method('hasItem')
->with(md5('option-' . $optionName))
->will($this->returnValue(true));
$ffprobe = $this->getFFProbeDriverMock();

View file

@ -2,10 +2,11 @@
namespace Tests\FFMpeg\Unit;
use FFMpeg\FFProbe;
use Symfony\Component\Process\ExecutableFinder;
use Alchemy\BinaryDriver\ConfigurationInterface;
use Alchemy\BinaryDriver\Configuration;
use Alchemy\BinaryDriver\ConfigurationInterface;
use FFMpeg\FFProbe;
use Symfony\Component\Cache\CacheItem;
use Symfony\Component\Process\ExecutableFinder;
class FFProbeTest extends TestCase
{
@ -100,13 +101,14 @@ class FFProbeTest extends TestCase
$cache = $this->getCacheMock();
$cache->expects($this->once())
->method('contains')
->method('hasItem')
->will($this->returnValue(false));
$cache->expects($this->never())
->method('fetch');
$cache->expects($this->once())
->method('getItem')
->will($this->returnValue(new CacheItem));
$cache->expects($this->once())
->method('save')
->with($this->anything(), $output);
->with($this->anything());
$driver = $this->getFFProbeDriverMock();
$driver->expects($this->once())
@ -160,10 +162,11 @@ class FFProbeTest extends TestCase
$cache = $this->getCacheMock();
$cache->expects($this->exactly(2))
->method('contains')
->method('hasItem')
->will($this->returnValue(false));
$cache->expects($this->never())
->method('fetch');
$cache->expects($this->once())
->method('getItem')
->will($this->returnValue(new CacheItem));
$driver = $this->getFFProbeDriverMock();
$driver->expects($this->exactly(2))
@ -205,13 +208,16 @@ class FFProbeTest extends TestCase
$tester = $this->getFFProbeOptionsTesterMock();
$cacheItem = new CacheItem;
$cacheItem->set($output);
$cache = $this->getCacheMock();
$cache->expects($this->once())
->method('contains')
->method('hasItem')
->will($this->returnValue(true));
$cache->expects($this->once())
->method('fetch')
->will($this->returnValue($output));
->method('getItem')
->will($this->returnValue($cacheItem));
$cache->expects($this->never())
->method('save');

View file

@ -695,12 +695,13 @@ class VideoTest extends AbstractStreamableTestCase
->method('getConfiguration')
->will($this->returnValue($configuration));
$self = $this;
$driver->expects($this->exactly(1))
->method('command')
->with($this->isType('array'), false, $this->anything())
->will($this->returnCallback(function ($commands, $errors, $listeners) {
var_dump($commands);
$this->assertTrue(!in_array('-b:v', $commands));
->will($this->returnCallback(function ($commands, $errors, $listeners) use ($self) {
$self->assertTrue(!in_array('-b:v', $commands));
}));
$video = new Video(__FILE__, $driver, $ffprobe);

View file

@ -52,7 +52,7 @@ class WaveformTest extends AbstractMediaTestCase
->method('command')
->with($commands);
$waveform = new Waveform($this->getAudioMock(__FILE__), $driver, $ffprobe, 640, 120, ['#FFFFFF']);
$waveform = new Waveform($this->getAudioMock(__FILE__), $driver, $ffprobe, 640, 120, array('#FFFFFF'));
$this->assertSame($waveform, $waveform->save($pathfile));
}

View file

@ -13,7 +13,7 @@ class TestCase extends BaseTestCase
public function getCacheMock()
{
return $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
return $this->getMockBuilder('Psr\Cache\CacheItemPoolInterface')->getMock();
}
public function getTimeCodeMock()