Merge remote-tracking branch 'upstream/master'

This commit is contained in:
CaliforniaMountainSnake 2020-02-26 09:43:23 +03:00
commit 580fb21d5a
45 changed files with 240 additions and 185 deletions

3
.gitignore vendored
View file

@ -4,5 +4,8 @@
composer.phar composer.phar
composer.lock composer.lock
phpunit.xml phpunit.xml
.phpunit.result.cache
/tests/Functional/output/output-*
sami.phar sami.phar
.idea/ .idea/
/phpunit

View file

@ -12,29 +12,49 @@ cache:
- $HOME/.composer/cache - $HOME/.composer/cache
- $HOME/.cache - $HOME/.cache
php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
matrix: matrix:
include: include:
- php: 5.4 - php: 5.4
env: COMPOSER_FLAGS="--prefer-lowest" env:
- PHPUNIT_VERSION=4
- COMPOSER_FLAGS="--prefer-lowest"
- php: 5.4
env:
- PHPUNIT_VERSION=4
- php: 5.5
env:
- PHPUNIT_VERSION=4
- php: 5.6
- php: 7.0
- php: 7.1
- php: 7.2
- php: 7.3
- php: 7.4
before_install: before_install:
- sudo add-apt-repository ppa:mc3man/trusty-media -y - sudo add-apt-repository ppa:mc3man/trusty-media -y
- sudo apt-get update -q - sudo apt-get update -q
- composer self-update - composer self-update
- if [ "$COMPOSER_FLAGS" == "--prefer-lowest" ]; then composer require "roave/security-advisories" dev-master --no-update; fi; - echo "$PHPUNIT_VERSION"
- |
if [ "$PHPUNIT_VERSION" ]; then
composer remove symfony/phpunit-bridge --dev
wget -O phpunit "https://phar.phpunit.de/phpunit-$PHPUNIT_VERSION.phar"
chmod +x phpunit
fi;
- |
if [ "$COMPOSER_FLAGS" == "--prefer-lowest" ]; then
composer require "roave/security-advisories" dev-master --no-update
fi;
install: install:
- sudo apt-get install -y ffmpeg - sudo apt-get install -y ffmpeg
- composer update --prefer-dist $COMPOSER_FLAGS - composer update --prefer-dist $COMPOSER_FLAGS
script: script:
- vendor/bin/phpunit --verbose - |
if [ "$PHPUNIT_VERSION" ]; then
./phpunit --verbose
else
./vendor/bin/simple-phpunit --verbose
fi;

View file

@ -44,7 +44,7 @@
"require-dev": { "require-dev": {
"sami/sami": "~1.0", "sami/sami": "~1.0",
"silex/silex": "~1.0", "silex/silex": "~1.0",
"phpunit/phpunit": "^4.8.36" "symfony/phpunit-bridge": "^5.0.4"
}, },
"autoload": { "autoload": {
"psr-0": { "psr-0": {

View file

@ -7,10 +7,13 @@
convertWarningsToExceptions="true" convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false"
syntaxCheck="true"
verbose="false" verbose="false"
bootstrap="tests/bootstrap.php" bootstrap="tests/bootstrap.php"
> >
<php>
<env name="SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT" value="true"/>
</php>
<testsuites> <testsuites>
<testsuite name="unit"> <testsuite name="unit">
<directory>tests/Unit</directory> <directory>tests/Unit</directory>
@ -21,10 +24,9 @@
</testsuites> </testsuites>
<filter> <filter>
<blacklist> <whitelist processUncoveredFilesFromWhitelist="true">
<directory>vendor</directory> <directory suffix=".php">src/</directory>
<directory>tests</directory> </whitelist>
</blacklist>
</filter> </filter>
</phpunit> </phpunit>

View file

@ -94,7 +94,7 @@ class Concat extends AbstractMediaType
$fileStream = @fopen($sourcesFile, 'w'); $fileStream = @fopen($sourcesFile, 'w');
if($fileStream === false) { if($fileStream === false) {
throw new ExecutionFailureException('Cannot open the temporary file.'); throw new RuntimeException('Cannot open the temporary file.');
} }
$count_videos = 0; $count_videos = 0;

52
tests/BaseTestCase.php Normal file
View file

@ -0,0 +1,52 @@
<?php
namespace Tests\FFMpeg;
use PHPUnit\Framework\TestCase;
/**
* This is a BC Layer to support phpunit 4.8 needed for php <= 5.5.
*/
if (class_exists('PHPUnit_Runner_Version')
&& version_compare(\PHPUnit_Runner_Version::id(), '5', '<')) {
class BaseTestCase extends TestCase
{
public static function assertScalar($value, $message = '')
{
self::assertTrue(is_scalar($value), $message);
}
public static function assertIsArray($value, $message = '')
{
self::assertTrue(is_array($value), $message);
}
public static function assertIsInt($value, $message = '')
{
self::assertTrue(is_int($value), $message);
}
public static function assertIsBool($value, $message = '')
{
self::assertTrue(is_bool($value), $message);
}
public static function assertIsString($value, $message = '')
{
self::assertTrue(is_string($value), $message);
}
public function expectException($exception, $message = null)
{
$this->setExpectedException($exception, $message);
}
}
} else {
class BaseTestCase extends TestCase
{
public function assertScalar($value, $message = '')
{
$this->assertTrue(is_scalar($value), $message);
}
}
}

View file

@ -25,11 +25,10 @@ class FFProbeTest extends FunctionalTestCase
$this->assertFalse($ffprobe->isValid(__DIR__ . '/../files/WrongFile.mp4')); $this->assertFalse($ffprobe->isValid(__DIR__ . '/../files/WrongFile.mp4'));
} }
/**
* @expectedException FFMpeg\Exception\RuntimeException
*/
public function testProbeOnNonExistantFile() public function testProbeOnNonExistantFile()
{ {
$this->expectException('\FFMpeg\Exception\RuntimeException');
$ffprobe = FFProbe::create(); $ffprobe = FFProbe::create();
$ffprobe->streams('/path/to/no/file'); $ffprobe->streams('/path/to/no/file');
} }

View file

@ -3,9 +3,9 @@
namespace Tests\FFMpeg\Functional; namespace Tests\FFMpeg\Functional;
use FFMpeg\FFMpeg; use FFMpeg\FFMpeg;
use PHPUnit\Framework\TestCase; use Tests\FFMpeg\BaseTestCase;
abstract class FunctionalTestCase extends TestCase abstract class FunctionalTestCase extends BaseTestCase
{ {
/** /**
* @return FFMpeg * @return FFMpeg

View file

@ -71,10 +71,10 @@ class VideoTranscodeTest extends FunctionalTestCase
} }
/** /**
* @expectedException \FFMpeg\Exception\RuntimeException
*/ */
public function testTranscodeInvalidFile() public function testTranscodeInvalidFile()
{ {
$this->expectException('\FFMpeg\Exception\RuntimeException');
$ffmpeg = $this->getFFMpeg(); $ffmpeg = $this->getFFMpeg();
$ffmpeg->open(__DIR__ . '/../files/UnknownFileTest.ogv'); $ffmpeg->open(__DIR__ . '/../files/UnknownFileTest.ogv');
} }
@ -84,7 +84,7 @@ class VideoTranscodeTest extends FunctionalTestCase
$ffmpeg = $this->getFFMpeg(); $ffmpeg = $this->getFFMpeg();
$video = new Video(__DIR__ . '/../files/UnknownFileTest.ogv', $ffmpeg->getFFMpegDriver(), $ffmpeg->getFFProbe()); $video = new Video(__DIR__ . '/../files/UnknownFileTest.ogv', $ffmpeg->getFFMpegDriver(), $ffmpeg->getFFProbe());
$this->setExpectedException('FFMpeg\Exception\RuntimeException'); $this->expectException('\FFMpeg\Exception\RuntimeException');
$video->save(new X264('aac'), __DIR__ . '/output/output-x264.mp4'); $video->save(new X264('aac'), __DIR__ . '/output/output-x264.mp4');
} }

View file

@ -9,10 +9,10 @@ class DimensionTest extends TestCase
{ {
/** /**
* @dataProvider provideInvalidDimensions * @dataProvider provideInvalidDimensions
* @expectedException FFMpeg\Exception\InvalidArgumentException
*/ */
public function testInvalidDimensions($width, $height) public function testInvalidDimensions($width, $height)
{ {
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
new Dimension($width, $height); new Dimension($width, $height);
} }

View file

@ -15,10 +15,10 @@ class FrameRateTest extends TestCase
/** /**
* @dataProvider provideInvalidFrameRates * @dataProvider provideInvalidFrameRates
* @expectedException FFMpeg\Exception\InvalidArgumentException
*/ */
public function testInvalidFrameRate($value) public function testInvalidFrameRate($value)
{ {
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
new FrameRate($value); new FrameRate($value);
} }

View file

@ -28,11 +28,9 @@ class TimeCodeTest extends TestCase
); );
} }
/**
* @expectedException FFMpeg\Exception\InvalidArgumentException
*/
public function testFromInvalidString() public function testFromInvalidString()
{ {
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
TimeCode::fromString('lalali lala'); TimeCode::fromString('lalali lala');
} }

View file

@ -41,11 +41,9 @@ class FFMpegDriverTest extends TestCase
$this->assertEquals($conf, $ffmpeg->getConfiguration()); $this->assertEquals($conf, $ffmpeg->getConfiguration());
} }
/**
* @expectedException FFMpeg\Exception\ExecutableNotFoundException
*/
public function testCreateFailureThrowsAnException() public function testCreateFailureThrowsAnException()
{ {
$this->expectException('\FFMpeg\Exception\ExecutableNotFoundException');
FFMpegDriver::create($this->getLoggerMock(), array('ffmpeg.binaries' => '/path/to/nowhere')); FFMpegDriver::create($this->getLoggerMock(), array('ffmpeg.binaries' => '/path/to/nowhere'));
} }
} }

View file

@ -41,11 +41,9 @@ class FFProbeDriverTest extends TestCase
$this->assertEquals($conf, $ffprobe->getConfiguration()); $this->assertEquals($conf, $ffprobe->getConfiguration());
} }
/**
* @expectedException FFMpeg\Exception\ExecutableNotFoundException
*/
public function testCreateFailureThrowsAnException() public function testCreateFailureThrowsAnException()
{ {
$this->expectException('\FFMpeg\Exception\ExecutableNotFoundException');
FFProbeDriver::create(array('ffprobe.binaries' => '/path/to/nowhere')); FFProbeDriver::create(array('ffprobe.binaries' => '/path/to/nowhere'));
} }
} }

View file

@ -4,9 +4,8 @@ namespace Tests\FFMpeg\Unit;
use FFMpeg\FFMpegServiceProvider; use FFMpeg\FFMpegServiceProvider;
use Silex\Application; use Silex\Application;
use PHPUnit\Framework\TestCase as BaseTestCase;
class FFMpegServiceProviderTest extends BaseTestCase class FFMpegServiceProviderTest extends TestCase
{ {
public function testWithConfig() public function testWithConfig()
{ {
@ -51,7 +50,7 @@ class FFMpegServiceProviderTest extends BaseTestCase
) )
)); ));
$this->setExpectedException('FFMpeg\Exception\ExecutableNotFoundException', 'Unable to load FFMpeg'); $this->expectException('\FFMpeg\Exception\ExecutableNotFoundException', 'Unable to load FFMpeg');
$app['ffmpeg']; $app['ffmpeg'];
} }
@ -64,7 +63,7 @@ class FFMpegServiceProviderTest extends BaseTestCase
) )
)); ));
$this->setExpectedException('FFMpeg\Exception\ExecutableNotFoundException', 'Unable to load FFProbe'); $this->expectException('\FFMpeg\Exception\ExecutableNotFoundException', 'Unable to load FFProbe');
$app['ffmpeg.ffprobe']; $app['ffmpeg.ffprobe'];
} }
} }

View file

@ -8,12 +8,12 @@ use FFMpeg\FFProbe\DataMapping\Stream;
class FFMpegTest extends TestCase class FFMpegTest extends TestCase
{ {
/**
* @expectedException \FFMpeg\Exception\RuntimeException
* @expectedExceptionMessage Unable to probe "/path/to/unknown/file".
*/
public function testOpenInvalid() public function testOpenInvalid()
{ {
$this->expectException(
'\FFMpeg\Exception\RuntimeException',
'Unable to probe "/path/to/unknown/file"'
);
$ffmpeg = new FFMpeg($this->getFFMpegDriverMock(), $this->getFFProbeMock()); $ffmpeg = new FFMpeg($this->getFFMpegDriverMock(), $this->getFFProbeMock());
$ffmpeg->open('/path/to/unknown/file'); $ffmpeg->open('/path/to/unknown/file');
} }
@ -57,11 +57,9 @@ class FFMpegTest extends TestCase
$this->assertInstanceOf('FFMpeg\Media\Video', $ffmpeg->open(__FILE__)); $this->assertInstanceOf('FFMpeg\Media\Video', $ffmpeg->open(__FILE__));
} }
/**
* @expectedException \FFMpeg\Exception\InvalidArgumentException
*/
public function testOpenUnknown() public function testOpenUnknown()
{ {
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
$ffprobe = $this->getFFProbeMock(); $ffprobe = $this->getFFProbeMock();
$ffprobe->expects($this->once()) $ffprobe->expects($this->once())
->method('streams') ->method('streams')

View file

@ -42,12 +42,12 @@ class StreamTest extends TestCase
); );
} }
/**
* @expectedException FFMpeg\Exception\LogicException
* @expectedExceptionMessage Dimensions can only be retrieved from video streams.
*/
public function testGetDimensionsFromAudio() public function testGetDimensionsFromAudio()
{ {
$this->expectException(
'\FFMpeg\Exception\LogicException',
'Dimensions can only be retrieved from video streams.'
);
$stream = new Stream(array('codec_type' => 'audio')); $stream = new Stream(array('codec_type' => 'audio'));
$stream->getDimensions(); $stream->getDimensions();
} }
@ -60,11 +60,13 @@ class StreamTest extends TestCase
/** /**
* @dataProvider provideInvalidPropertiesForDimensionsExtraction * @dataProvider provideInvalidPropertiesForDimensionsExtraction
* @expectedException FFMpeg\Exception\RuntimeException
* @expectedExceptionMessage Unable to extract dimensions.
*/ */
public function testUnableToGetDimensionsFromVideo($properties) public function testUnableToGetDimensionsFromVideo($properties)
{ {
$this->expectException(
'\FFMpeg\Exception\RuntimeException',
'Unable to extract dimensions.'
);
$stream = new Stream(array('codec_type' => 'video', 'width' => 960)); $stream = new Stream(array('codec_type' => 'video', 'width' => 960));
$stream->getDimensions(); $stream->getDimensions();
} }

View file

@ -20,11 +20,9 @@ class MapperTest extends TestCase
$this->assertEquals($expected, $mapper->map($type, $data)); $this->assertEquals($expected, $mapper->map($type, $data));
} }
/**
* @expectedException FFMpeg\Exception\InvalidArgumentException
*/
public function testMapInvalidArgument() public function testMapInvalidArgument()
{ {
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
$mapper = new Mapper(); $mapper = new Mapper();
$mapper->map('cool type', 'data'); $mapper->map('cool type', 'data');
} }

View file

@ -2,25 +2,28 @@
namespace Tests\FFMpeg\Unit\FFProbe; namespace Tests\FFMpeg\Unit\FFProbe;
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
use Tests\FFMpeg\Unit\TestCase; use Tests\FFMpeg\Unit\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() public function testHasOptionWithOldFFProbe()
{ {
$this->expectException(
'\FFMpeg\Exception\RuntimeException',
'Your FFProbe version is too old and does not support `-help` option, please upgrade.'
);
$cache = $this->getCacheMock(); $cache = $this->getCacheMock();
$executionFailerExceptionMock = $this->getMockBuilder('Alchemy\BinaryDriver\Exception\ExecutionFailureException')
->disableOriginalConstructor()
->getMock();
$ffprobe = $this->getFFProbeDriverMock(); $ffprobe = $this->getFFProbeDriverMock();
$ffprobe->expects($this->once()) $ffprobe->expects($this->once())
->method('command') ->method('command')
->with(array('-help', '-loglevel', 'quiet')) ->with(array('-help', '-loglevel', 'quiet'))
->will($this->throwException(new ExecutionFailureException('Failed to execute'))); ->will($this->throwException($executionFailerExceptionMock));
$tester = new OptionsTester($ffprobe, $cache); $tester = new OptionsTester($ffprobe, $cache);
$tester->has('-print_format'); $tester->has('-print_format');

View file

@ -17,11 +17,9 @@ class OutputParserTest extends TestCase
$this->assertEquals($expectedOutput, $parser->parse($type, $data)); $this->assertEquals($expectedOutput, $parser->parse($type, $data));
} }
/**
* @expectedException FFMpeg\Exception\InvalidArgumentException
*/
public function testParseWithInvalidArgument() public function testParseWithInvalidArgument()
{ {
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
$parser = new OutputParser(); $parser = new OutputParser();
$parser->parse('comme ca', 'data'); $parser->parse('comme ca', 'data');
} }

View file

@ -236,11 +236,11 @@ class FFProbeTest extends TestCase
} }
/** /**
* @expectedException FFMpeg\Exception\RuntimeException
* @dataProvider provideProbeMethod * @dataProvider provideProbeMethod
*/ */
public function testProbeWithoutShowStreamsAvailable($method) public function testProbeWithoutShowStreamsAvailable($method)
{ {
$this->expectException('\FFMpeg\Exception\RuntimeException');
$pathfile = __FILE__; $pathfile = __FILE__;
$ffprobe = new FFProbe($this->getFFProbeDriverMock(), $this->getCacheMock()); $ffprobe = new FFProbe($this->getFFProbeDriverMock(), $this->getCacheMock());

View file

@ -18,7 +18,7 @@ class AudioClipTest extends TestCase {
->will($this->returnCallback(function ($filter) use (&$capturedFilter) { ->will($this->returnCallback(function ($filter) use (&$capturedFilter) {
$capturedFilter = $filter; $capturedFilter = $filter;
})); }));
$format = $this->getMock('FFMpeg\Format\AudioInterface'); $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
$filters = new AudioFilters($audio); $filters = new AudioFilters($audio);
@ -36,7 +36,7 @@ class AudioClipTest extends TestCase {
->will($this->returnCallback(function ($filter) use (&$capturedFilter) { ->will($this->returnCallback(function ($filter) use (&$capturedFilter) {
$capturedFilter = $filter; $capturedFilter = $filter;
})); }));
$format = $this->getMock('FFMpeg\Format\AudioInterface'); $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
$filters = new AudioFilters($audio); $filters = new AudioFilters($audio);

View file

@ -18,7 +18,7 @@ class AudioMetadataTest extends TestCase
->will($this->returnCallback(function ($filter) use (&$capturedFilter) { ->will($this->returnCallback(function ($filter) use (&$capturedFilter) {
$capturedFilter = $filter; $capturedFilter = $filter;
})); }));
$format = $this->getMock('FFMpeg\Format\AudioInterface'); $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
$filters = new AudioFilters($audio); $filters = new AudioFilters($audio);
$filters->addMetadata(array('title' => "Hello World")); $filters->addMetadata(array('title' => "Hello World"));
@ -36,7 +36,7 @@ class AudioMetadataTest extends TestCase
->will($this->returnCallback(function ($filter) use (&$capturedFilter) { ->will($this->returnCallback(function ($filter) use (&$capturedFilter) {
$capturedFilter = $filter; $capturedFilter = $filter;
})); }));
$format = $this->getMock('FFMpeg\Format\AudioInterface'); $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
$filters = new AudioFilters($audio); $filters = new AudioFilters($audio);
$filters->addMetadata(array('genre' => 'Some Genre', 'artwork' => "/path/to/file.jpg")); $filters->addMetadata(array('genre' => 'Some Genre', 'artwork' => "/path/to/file.jpg"));
@ -55,7 +55,7 @@ class AudioMetadataTest extends TestCase
->will($this->returnCallback(function ($filter) use (&$capturedFilter) { ->will($this->returnCallback(function ($filter) use (&$capturedFilter) {
$capturedFilter = $filter; $capturedFilter = $filter;
})); }));
$format = $this->getMock('FFMpeg\Format\AudioInterface'); $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
$filters = new AudioFilters($audio); $filters = new AudioFilters($audio);
$filters->addMetadata(); $filters->addMetadata();

View file

@ -16,7 +16,7 @@ class AudioResamplableFilterTest extends TestCase
public function testApply() public function testApply()
{ {
$audio = $this->getAudioMock(); $audio = $this->getAudioMock();
$format = $this->getMock('FFMpeg\Format\AudioInterface'); $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
$filter = new AudioResamplableFilter(500); $filter = new AudioResamplableFilter(500);
$this->assertEquals(array('-ac', 2, '-ar', 500), $filter->apply($audio, $format)); $this->assertEquals(array('-ac', 2, '-ar', 500), $filter->apply($audio, $format));

View file

@ -12,7 +12,7 @@ class CustomFilterTest extends TestCase
public function testApplyCustomFilter() public function testApplyCustomFilter()
{ {
$audio = $this->getAudioMock(); $audio = $this->getAudioMock();
$format = $this->getMock('FFMpeg\Format\AudioInterface'); $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
$filter = new CustomFilter('whatever i put would end up as a filter'); $filter = new CustomFilter('whatever i put would end up as a filter');
$this->assertEquals(array('-af', 'whatever i put would end up as a filter'), $filter->apply($audio, $format)); $this->assertEquals(array('-af', 'whatever i put would end up as a filter'), $filter->apply($audio, $format));

View file

@ -13,18 +13,18 @@ class FiltersCollectionTest extends TestCase
$coll = new FiltersCollection(); $coll = new FiltersCollection();
$this->assertCount(0, $coll); $this->assertCount(0, $coll);
$coll->add($this->getMock('FFMpeg\Filters\FilterInterface')); $coll->add($this->getMockBuilder('FFMpeg\Filters\FilterInterface')->getMock());
$this->assertCount(1, $coll); $this->assertCount(1, $coll);
$coll->add($this->getMock('FFMpeg\Filters\FilterInterface')); $coll->add($this->getMockBuilder('FFMpeg\Filters\FilterInterface')->getMock());
$this->assertCount(2, $coll); $this->assertCount(2, $coll);
} }
public function testIterator() public function testIterator()
{ {
$coll = new FiltersCollection(); $coll = new FiltersCollection();
$coll->add($this->getMock('FFMpeg\Filters\FilterInterface')); $coll->add($this->getMockBuilder('FFMpeg\Filters\FilterInterface')->getMock());
$coll->add($this->getMock('FFMpeg\Filters\FilterInterface')); $coll->add($this->getMockBuilder('FFMpeg\Filters\FilterInterface')->getMock());
$this->assertInstanceOf('\ArrayIterator', $coll->getIterator()); $this->assertInstanceOf('\ArrayIterator', $coll->getIterator());
$this->assertCount(2, $coll->getIterator()); $this->assertCount(2, $coll->getIterator());
@ -51,7 +51,7 @@ class FiltersCollectionTest extends TestCase
$data = array(); $data = array();
$video = $this->getVideoMock(); $video = $this->getVideoMock();
$format = $this->getMock('FFMpeg\Format\AudioInterface'); $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
foreach ($coll as $filter) { foreach ($coll as $filter) {
$data = array_merge($data, $filter->apply($video, $format)); $data = array_merge($data, $filter->apply($video, $format));

View file

@ -22,7 +22,7 @@ class CropFilterTest extends TestCase
->method('getStreams') ->method('getStreams')
->will($this->returnValue($streams)); ->will($this->returnValue($streams));
$format = $this->getMock('FFMpeg\Format\VideoInterface'); $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$dimension = new Dimension(200, 150); $dimension = new Dimension(200, 150);
$point = new Point(25, 35); $point = new Point(25, 35);

View file

@ -12,7 +12,7 @@ class CustomFilterTest extends TestCase
public function testApplyCustomFilter() public function testApplyCustomFilter()
{ {
$video = $this->getVideoMock(); $video = $this->getVideoMock();
$format = $this->getMock('FFMpeg\Format\VideoInterface'); $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$filter = new CustomFilter('whatever i put would end up as a filter'); $filter = new CustomFilter('whatever i put would end up as a filter');
$this->assertEquals(array('-vf', 'whatever i put would end up as a filter'), $filter->apply($video, $format)); $this->assertEquals(array('-vf', 'whatever i put would end up as a filter'), $filter->apply($video, $format));

View file

@ -17,7 +17,7 @@ class ExtractMultipleFramesFilterTest extends TestCase
$video = $this->getVideoMock(); $video = $this->getVideoMock();
$pathfile = '/path/to/file'.mt_rand(); $pathfile = '/path/to/file'.mt_rand();
$format = $this->getMock('FFMpeg\Format\VideoInterface'); $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$format->expects($this->any()) $format->expects($this->any())
->method('getModulus') ->method('getModulus')
->will($this->returnValue($modulus)); ->will($this->returnValue($modulus));
@ -64,10 +64,8 @@ class ExtractMultipleFramesFilterTest extends TestCase
); );
} }
/**
* @expectedException \FFMpeg\Exception\InvalidArgumentException
*/
public function testInvalidFrameFileType() { public function testInvalidFrameFileType() {
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
$filter = new ExtractMultipleFramesFilter('1/1', '/'); $filter = new ExtractMultipleFramesFilter('1/1', '/');
$filter->setFrameFileType('webm'); $filter->setFrameFileType('webm');
} }

View file

@ -14,7 +14,7 @@ class FrameRateFilterTest extends TestCase
$gop = 42; $gop = 42;
$video = $this->getVideoMock(); $video = $this->getVideoMock();
$format = $this->getMock('FFMpeg\Format\VideoInterface'); $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$format->expects($this->any()) $format->expects($this->any())
->method('supportBFrames') ->method('supportBFrames')
->will($this->returnValue(true)); ->will($this->returnValue(true));
@ -31,7 +31,7 @@ class FrameRateFilterTest extends TestCase
$gop = 42; $gop = 42;
$video = $this->getVideoMock(); $video = $this->getVideoMock();
$format = $this->getMock('FFMpeg\Format\VideoInterface'); $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$format->expects($this->any()) $format->expects($this->any())
->method('supportBFrames') ->method('supportBFrames')
->will($this->returnValue(false)); ->will($this->returnValue(false));

View file

@ -18,7 +18,7 @@ class PadFilterTest extends TestCase
$video = $this->getVideoMock(); $video = $this->getVideoMock();
$pathfile = '/path/to/file'.mt_rand(); $pathfile = '/path/to/file'.mt_rand();
$format = $this->getMock('FFMpeg\Format\VideoInterface'); $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$streams = new StreamCollection(array( $streams = new StreamCollection(array(
new Stream(array( new Stream(array(

View file

@ -18,7 +18,7 @@ class ResizeFilterTest extends TestCase
$video = $this->getVideoMock(); $video = $this->getVideoMock();
$pathfile = '/path/to/file'.mt_rand(); $pathfile = '/path/to/file'.mt_rand();
$format = $this->getMock('FFMpeg\Format\VideoInterface'); $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$format->expects($this->any()) $format->expects($this->any())
->method('getModulus') ->method('getModulus')
->will($this->returnValue($modulus)); ->will($this->returnValue($modulus));

View file

@ -22,7 +22,7 @@ class RotateFilterTest extends TestCase
->method('getStreams') ->method('getStreams')
->will($this->returnValue($streams)); ->will($this->returnValue($streams));
$format = $this->getMock('FFMpeg\Format\VideoInterface'); $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$filter = new RotateFilter($value); $filter = new RotateFilter($value);
$this->assertEquals(array('-vf', $value, '-metadata:s:v:0', 'rotate=0'), $filter->apply($video, $format)); $this->assertEquals(array('-vf', $value, '-metadata:s:v:0', 'rotate=0'), $filter->apply($video, $format));
@ -48,7 +48,7 @@ class RotateFilterTest extends TestCase
$video->expects($this->never()) $video->expects($this->never())
->method('getStreams'); ->method('getStreams');
$format = $this->getMock('FFMpeg\Format\VideoInterface'); $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$filter = new RotateFilter($value); $filter = new RotateFilter($value);
$this->assertEquals(array('-vf', $value, '-metadata:s:v:0', 'rotate=0'), $filter->apply($video, $format)); $this->assertEquals(array('-vf', $value, '-metadata:s:v:0', 'rotate=0'), $filter->apply($video, $format));
@ -61,12 +61,12 @@ class RotateFilterTest extends TestCase
); );
} }
/**
* @expectedException \FFMpeg\Exception\InvalidArgumentException
* @expectedExceptionMessage Invalid angle value.
*/
public function testApplyInvalidAngle() public function testApplyInvalidAngle()
{ {
$this->expectException(
'\FFMpeg\Exception\InvalidArgumentException',
'Invalid angle value.'
);
new RotateFilter('90'); new RotateFilter('90');
} }
} }

View file

@ -10,7 +10,7 @@ class SynchronizeFilterTest extends TestCase
public function testApply() public function testApply()
{ {
$video = $this->getVideoMock(); $video = $this->getVideoMock();
$format = $this->getMock('FFMpeg\Format\VideoInterface'); $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$filter = new SynchronizeFilter(); $filter = new SynchronizeFilter();
$this->assertEquals(array('-async', '1', '-metadata:s:v:0', 'start_time=0'), $filter->apply($video, $format)); $this->assertEquals(array('-async', '1', '-metadata:s:v:0', 'start_time=0'), $filter->apply($video, $format));

View file

@ -17,7 +17,7 @@ class WatermarkFilterTest extends TestCase
$video = $this->getVideoMock(); $video = $this->getVideoMock();
$format = $this->getMock('FFMpeg\Format\VideoInterface'); $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$filter = new WatermarkFilter(__DIR__ . '/../../../files/watermark.png'); $filter = new WatermarkFilter(__DIR__ . '/../../../files/watermark.png');
$this->assertEquals(array('-vf', 'movie='.__DIR__ .'/../../../files/watermark.png [watermark]; [in][watermark] overlay=0:0 [out]'), $filter->apply($video, $format)); $this->assertEquals(array('-vf', 'movie='.__DIR__ .'/../../../files/watermark.png [watermark]; [in][watermark] overlay=0:0 [out]'), $filter->apply($video, $format));
@ -30,7 +30,7 @@ class WatermarkFilterTest extends TestCase
public function testDifferentCoordinaates() public function testDifferentCoordinaates()
{ {
$video = $this->getVideoMock(); $video = $this->getVideoMock();
$format = $this->getMock('FFMpeg\Format\VideoInterface'); $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
// test position absolute // test position absolute
$filter = new WatermarkFilter(__DIR__ . '/../../../files/watermark.png', array( $filter = new WatermarkFilter(__DIR__ . '/../../../files/watermark.png', array(

View file

@ -9,7 +9,11 @@ abstract class AudioTestCase extends TestCase
{ {
public function testExtraParams() public function testExtraParams()
{ {
foreach ($this->getFormat()->getExtraParams() as $param) { $extraParams = $this->getFormat()->getExtraParams();
$this->assertIsArray($extraParams);
foreach ($extraParams as $param) {
$this->assertScalar($param); $this->assertScalar($param);
} }
} }
@ -30,11 +34,9 @@ abstract class AudioTestCase extends TestCase
} }
} }
/**
* @expectedException FFMpeg\Exception\InvalidArgumentException
*/
public function testSetInvalidAudioCodec() public function testSetInvalidAudioCodec()
{ {
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
$this->getFormat()->setAudioCodec('invalid-random-audio-codec'); $this->getFormat()->setAudioCodec('invalid-random-audio-codec');
} }
@ -45,7 +47,7 @@ abstract class AudioTestCase extends TestCase
public function testGetAudioKiloBitrate() public function testGetAudioKiloBitrate()
{ {
$this->assertInternalType('integer', $this->getFormat()->getAudioKiloBitrate()); $this->assertIsInt($this->getFormat()->getAudioKiloBitrate());
} }
public function testSetAudioKiloBitrate() public function testSetAudioKiloBitrate()
@ -55,25 +57,21 @@ abstract class AudioTestCase extends TestCase
$this->assertEquals(256, $format->getAudioKiloBitrate()); $this->assertEquals(256, $format->getAudioKiloBitrate());
} }
/**
* @expectedException FFMpeg\Exception\InvalidArgumentException
*/
public function testSetInvalidKiloBitrate() public function testSetInvalidKiloBitrate()
{ {
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
$this->getFormat()->setAudioKiloBitrate(0); $this->getFormat()->setAudioKiloBitrate(0);
} }
/**
* @expectedException FFMpeg\Exception\InvalidArgumentException
*/
public function testSetNegativeKiloBitrate() public function testSetNegativeKiloBitrate()
{ {
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
$this->getFormat()->setAudioKiloBitrate(-10); $this->getFormat()->setAudioKiloBitrate(-10);
} }
public function testGetAudioChannels() public function testGetAudioChannels()
{ {
$this->assertInternalType('null', $this->getFormat()->getAudioChannels()); $this->assertNull($this->getFormat()->getAudioChannels());
} }
public function testSetAudioChannels() public function testSetAudioChannels()
@ -83,25 +81,21 @@ abstract class AudioTestCase extends TestCase
$this->assertEquals(2, $format->getAudioChannels()); $this->assertEquals(2, $format->getAudioChannels());
} }
/**
* @expectedException FFMpeg\Exception\InvalidArgumentException
*/
public function testSetInvalidChannels() public function testSetInvalidChannels()
{ {
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
$this->getFormat()->setAudioChannels(0); $this->getFormat()->setAudioChannels(0);
} }
/**
* @expectedException FFMpeg\Exception\InvalidArgumentException
*/
public function testSetNegativeChannels() public function testSetNegativeChannels()
{ {
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
$this->getFormat()->setAudioChannels(-10); $this->getFormat()->setAudioChannels(-10);
} }
public function testCreateProgressListener() public function testCreateProgressListener()
{ {
$media = $this->getMock('FFMpeg\Media\MediaTypeInterface'); $media = $this->getMockBuilder('FFMpeg\Media\MediaTypeInterface')->getMock();
$media->expects($this->any()) $media->expects($this->any())
->method('getPathfile') ->method('getPathfile')
->will($this->returnValue(__FILE__)); ->will($this->returnValue(__FILE__));

View file

@ -14,7 +14,7 @@ abstract class VideoTestCase extends AudioTestCase
public function testSupportBFrames() public function testSupportBFrames()
{ {
$this->assertInternalType('boolean', $this->getFormat()->supportBFrames()); $this->assertIsBool($this->getFormat()->supportBFrames());
} }
public function testSetVideoCodec() public function testSetVideoCodec()
@ -29,7 +29,7 @@ abstract class VideoTestCase extends AudioTestCase
public function testGetKiloBitrate() public function testGetKiloBitrate()
{ {
$this->assertInternalType('integer', $this->getFormat()->getKiloBitrate()); $this->assertIsInt($this->getFormat()->getKiloBitrate());
} }
public function testSetKiloBitrate() public function testSetKiloBitrate()
@ -39,11 +39,9 @@ abstract class VideoTestCase extends AudioTestCase
$this->assertEquals(2560, $format->getKiloBitrate()); $this->assertEquals(2560, $format->getKiloBitrate());
} }
/**
* @expectedException FFMpeg\Exception\InvalidArgumentException
*/
public function testSetInvalidVideoCodec() public function testSetInvalidVideoCodec()
{ {
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
$this->getFormat()->setVideoCodec('invalid-random-video-codec'); $this->getFormat()->setVideoCodec('invalid-random-video-codec');
} }
@ -54,7 +52,7 @@ abstract class VideoTestCase extends AudioTestCase
public function testCreateProgressListener() public function testCreateProgressListener()
{ {
$media = $this->getMock('FFMpeg\Media\MediaTypeInterface'); $media = $this->getMockBuilder('FFMpeg\Media\MediaTypeInterface')->getMock();
$media->expects($this->any()) $media->expects($this->any())
->method('getPathfile') ->method('getPathfile')
->will($this->returnValue(__FILE__)); ->will($this->returnValue(__FILE__));
@ -72,13 +70,13 @@ abstract class VideoTestCase extends AudioTestCase
public function testGetPasses() public function testGetPasses()
{ {
$this->assertInternalType('integer', $this->getFormat()->getPasses()); $this->assertIsInt($this->getFormat()->getPasses());
$this->assertGreaterThan(0, $this->getFormat()->getPasses()); $this->assertGreaterThan(0, $this->getFormat()->getPasses());
} }
public function testGetModulus() public function testGetModulus()
{ {
$this->assertInternalType('integer', $this->getFormat()->getModulus()); $this->assertIsInt($this->getFormat()->getModulus());
$this->assertGreaterThan(0, $this->getFormat()->getModulus()); $this->assertGreaterThan(0, $this->getFormat()->getModulus());
$this->assertEquals(0, $this->getFormat()->getModulus() % 2); $this->assertEquals(0, $this->getFormat()->getModulus() % 2);
} }

View file

@ -2,6 +2,7 @@
namespace Tests\FFMpeg\Unit\Media; namespace Tests\FFMpeg\Unit\Media;
use FFMpeg\Exception\RuntimeException;
use FFMpeg\Media\Audio; use FFMpeg\Media\Audio;
use Alchemy\BinaryDriver\Exception\ExecutionFailureException; use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
use FFMpeg\Format\AudioInterface; use FFMpeg\Format\AudioInterface;
@ -29,7 +30,7 @@ class AudioTest extends AbstractStreamableTestCase
$audio = new Audio(__FILE__, $driver, $ffprobe); $audio = new Audio(__FILE__, $driver, $ffprobe);
$audio->setFiltersCollection($filters); $audio->setFiltersCollection($filters);
$filter = $this->getMock('FFMpeg\Filters\Audio\AudioFilterInterface'); $filter = $this->getMockBuilder('FFMpeg\Filters\Audio\AudioFilterInterface')->getMock();
$filters->expects($this->once()) $filters->expects($this->once())
->method('add') ->method('add')
@ -50,12 +51,12 @@ class AudioTest extends AbstractStreamableTestCase
$audio = new Audio(__FILE__, $driver, $ffprobe); $audio = new Audio(__FILE__, $driver, $ffprobe);
$audio->setFiltersCollection($filters); $audio->setFiltersCollection($filters);
$filter = $this->getMock('FFMpeg\Filters\Video\VideoFilterInterface'); $filter = $this->getMockBuilder('FFMpeg\Filters\Video\VideoFilterInterface')->getMock();
$filters->expects($this->never()) $filters->expects($this->never())
->method('add'); ->method('add');
$this->setExpectedException('FFMpeg\Exception\InvalidArgumentException'); $this->expectException('\FFMpeg\Exception\InvalidArgumentException');
$audio->addFilter($filter); $audio->addFilter($filter);
} }
@ -65,24 +66,24 @@ class AudioTest extends AbstractStreamableTestCase
$ffprobe = $this->getFFProbeMock(); $ffprobe = $this->getFFProbeMock();
$outputPathfile = '/target/file'; $outputPathfile = '/target/file';
$format = $this->getMock('FFMpeg\Format\AudioInterface'); $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
$format->expects($this->any()) $format->expects($this->any())
->method('getExtraParams') ->method('getExtraParams')
->will($this->returnValue(array())); ->will($this->returnValue(array()));
$configuration = $this->getMock('Alchemy\BinaryDriver\ConfigurationInterface'); $configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock();
$driver->expects($this->any()) $driver->expects($this->any())
->method('getConfiguration') ->method('getConfiguration')
->will($this->returnValue($configuration)); ->will($this->returnValue($configuration));
$failure = new ExecutionFailureException('failed to encode'); $failure = new RuntimeException('failed to encode');
$driver->expects($this->once()) $driver->expects($this->once())
->method('command') ->method('command')
->will($this->throwException($failure)); ->will($this->throwException($failure));
$audio = new Audio(__FILE__, $driver, $ffprobe); $audio = new Audio(__FILE__, $driver, $ffprobe);
$this->setExpectedException('FFMpeg\Exception\RuntimeException'); $this->expectException('\FFMpeg\Exception\RuntimeException');
$audio->save($format, $outputPathfile); $audio->save($format, $outputPathfile);
} }
@ -91,12 +92,12 @@ class AudioTest extends AbstractStreamableTestCase
$driver = $this->getFFMpegDriverMock(); $driver = $this->getFFMpegDriverMock();
$ffprobe = $this->getFFProbeMock(); $ffprobe = $this->getFFProbeMock();
$outputPathfile = '/target/file'; $outputPathfile = '/target/file';
$format = $this->getMock('FFMpeg\Format\AudioInterface'); $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
$format->expects($this->any()) $format->expects($this->any())
->method('getExtraParams') ->method('getExtraParams')
->will($this->returnValue(array())); ->will($this->returnValue(array()));
$configuration = $this->getMock('Alchemy\BinaryDriver\ConfigurationInterface'); $configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock();
$driver->expects($this->any()) $driver->expects($this->any())
->method('getConfiguration') ->method('getConfiguration')
@ -104,7 +105,7 @@ class AudioTest extends AbstractStreamableTestCase
$audio = new Audio(__FILE__, $driver, $ffprobe); $audio = new Audio(__FILE__, $driver, $ffprobe);
$filter = $this->getMock('FFMpeg\Filters\Audio\AudioFilterInterface'); $filter = $this->getMockBuilder('FFMpeg\Filters\Audio\AudioFilterInterface')->getMock();
$filter->expects($this->once()) $filter->expects($this->once())
->method('apply') ->method('apply')
->with($audio, $format) ->with($audio, $format)
@ -138,7 +139,7 @@ class AudioTest extends AbstractStreamableTestCase
$driver = $this->getFFMpegDriverMock(); $driver = $this->getFFMpegDriverMock();
$ffprobe = $this->getFFProbeMock(); $ffprobe = $this->getFFProbeMock();
$configuration = $this->getMock('Alchemy\BinaryDriver\ConfigurationInterface'); $configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock();
$driver->expects($this->any()) $driver->expects($this->any())
->method('getConfiguration') ->method('getConfiguration')
@ -180,7 +181,7 @@ class AudioTest extends AbstractStreamableTestCase
public function provideSaveData() public function provideSaveData()
{ {
$format = $this->getMock('FFMpeg\Format\AudioInterface'); $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
$format->expects($this->any()) $format->expects($this->any())
->method('getExtraParams') ->method('getExtraParams')
->will($this->returnValue(array())); ->will($this->returnValue(array()));
@ -191,7 +192,7 @@ class AudioTest extends AbstractStreamableTestCase
->method('getAudioChannels') ->method('getAudioChannels')
->will($this->returnValue(5)); ->will($this->returnValue(5));
$audioFormat = $this->getMock('FFMpeg\Format\AudioInterface'); $audioFormat = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
$audioFormat->expects($this->any()) $audioFormat->expects($this->any())
->method('getExtraParams') ->method('getExtraParams')
->will($this->returnValue(array())); ->will($this->returnValue(array()));
@ -205,7 +206,7 @@ class AudioTest extends AbstractStreamableTestCase
->method('getAudioCodec') ->method('getAudioCodec')
->will($this->returnValue('patati-patata-audio')); ->will($this->returnValue('patati-patata-audio'));
$formatExtra = $this->getMock('FFMpeg\Format\AudioInterface'); $formatExtra = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
$formatExtra->expects($this->any()) $formatExtra->expects($this->any())
->method('getExtraParams') ->method('getExtraParams')
->will($this->returnValue(array('extra', 'param'))); ->will($this->returnValue(array('extra', 'param')));
@ -216,7 +217,7 @@ class AudioTest extends AbstractStreamableTestCase
->method('getAudioChannels') ->method('getAudioChannels')
->will($this->returnValue(5)); ->will($this->returnValue(5));
$listeners = array($this->getMock('Alchemy\BinaryDriver\Listeners\ListenerInterface')); $listeners = array($this->getMockBuilder('Alchemy\BinaryDriver\Listeners\ListenerInterface')->getMock());
$progressableFormat = $this->getMockBuilder('Tests\FFMpeg\Unit\Media\AudioProg') $progressableFormat = $this->getMockBuilder('Tests\FFMpeg\Unit\Media\AudioProg')
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
@ -290,7 +291,7 @@ class AudioTest extends AbstractStreamableTestCase
$driver = $this->getFFMpegDriverMock(); $driver = $this->getFFMpegDriverMock();
$ffprobe = $this->getFFProbeMock(); $ffprobe = $this->getFFProbeMock();
$configuration = $this->getMock('Alchemy\BinaryDriver\ConfigurationInterface'); $configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock();
$driver->expects($this->any()) $driver->expects($this->any())
->method('getConfiguration') ->method('getConfiguration')
@ -317,7 +318,7 @@ class AudioTest extends AbstractStreamableTestCase
$outputPathfile = '/target/file'; $outputPathfile = '/target/file';
$format = $this->getMock('FFMpeg\Format\AudioInterface'); $format = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
$format->expects($this->any()) $format->expects($this->any())
->method('getExtraParams') ->method('getExtraParams')
->will($this->returnValue(array('param'))); ->will($this->returnValue(array('param')));

View file

@ -35,7 +35,7 @@ class ClipTest extends AbstractMediaTestCase
$outputPathfile = '/target/file'; $outputPathfile = '/target/file';
$format = $this->getMock('FFMpeg\Format\VideoInterface'); $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$format->expects($this->any()) $format->expects($this->any())
->method('getPasses') ->method('getPasses')
->will($this->returnValue(1)); ->will($this->returnValue(1));

View file

@ -34,7 +34,7 @@ class ConcatTest extends AbstractMediaTestCase
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$filter = $this->getMock('FFMpeg\Filters\Concat\ConcatFilterInterface'); $filter = $this->getMockBuilder('FFMpeg\Filters\Concat\ConcatFilterInterface')->getMock();
$filters->expects($this->once()) $filters->expects($this->once())
->method('add') ->method('add')
@ -115,7 +115,7 @@ class ConcatTest extends AbstractMediaTestCase
array_push($commands, $pathfile); array_push($commands, $pathfile);
$configuration = $this->getMock('Alchemy\BinaryDriver\ConfigurationInterface'); $configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock();
$driver->expects($this->any()) $driver->expects($this->any())
->method('getConfiguration') ->method('getConfiguration')

View file

@ -36,7 +36,7 @@ class FrameTest extends AbstractMediaTestCase
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$filter = $this->getMock('FFMpeg\Filters\Frame\FrameFilterInterface'); $filter = $this->getMockBuilder('FFMpeg\Filters\Frame\FrameFilterInterface')->getMock();
$filters->expects($this->once()) $filters->expects($this->once())
->method('add') ->method('add')

View file

@ -51,7 +51,7 @@ class GifTest extends AbstractMediaTestCase
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$filter = $this->getMock('FFMpeg\Filters\Gif\GifFilterInterface'); $filter = $this->getMockBuilder('FFMpeg\Filters\Gif\GifFilterInterface')->getMock();
$filters->expects($this->once()) $filters->expects($this->once())
->method('add') ->method('add')

View file

@ -2,6 +2,7 @@
namespace Tests\FFMpeg\Unit\Media; namespace Tests\FFMpeg\Unit\Media;
use FFMpeg\Exception\RuntimeException;
use FFMpeg\Media\Video; use FFMpeg\Media\Video;
use Alchemy\BinaryDriver\Exception\ExecutionFailureException; use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
use FFMpeg\Format\VideoInterface; use FFMpeg\Format\VideoInterface;
@ -29,7 +30,7 @@ class VideoTest extends AbstractStreamableTestCase
$video = new Video(__FILE__, $driver, $ffprobe); $video = new Video(__FILE__, $driver, $ffprobe);
$video->setFiltersCollection($filters); $video->setFiltersCollection($filters);
$filter = $this->getMock('FFMpeg\Filters\Video\VideoFilterInterface'); $filter = $this->getMockBuilder('FFMpeg\Filters\Video\VideoFilterInterface')->getMock();
$filters->expects($this->once()) $filters->expects($this->once())
->method('add') ->method('add')
@ -50,7 +51,7 @@ class VideoTest extends AbstractStreamableTestCase
$video = new Video(__FILE__, $driver, $ffprobe); $video = new Video(__FILE__, $driver, $ffprobe);
$video->setFiltersCollection($filters); $video->setFiltersCollection($filters);
$filter = $this->getMock('FFMpeg\Filters\Audio\AudioFilterInterface'); $filter = $this->getMockBuilder('FFMpeg\Filters\Audio\AudioFilterInterface')->getMock();
$filters->expects($this->once()) $filters->expects($this->once())
->method('add') ->method('add')
@ -79,7 +80,7 @@ class VideoTest extends AbstractStreamableTestCase
$driver = $this->getFFMpegDriverMock(); $driver = $this->getFFMpegDriverMock();
$ffprobe = $this->getFFProbeMock(); $ffprobe = $this->getFFProbeMock();
$outputPathfile = '/target/file'; $outputPathfile = '/target/file';
$format = $this->getMock('FFMpeg\Format\VideoInterface'); $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$format->expects($this->any()) $format->expects($this->any())
->method('getPasses') ->method('getPasses')
->will($this->returnValue(1)); ->will($this->returnValue(1));
@ -87,19 +88,19 @@ class VideoTest extends AbstractStreamableTestCase
->method('getExtraParams') ->method('getExtraParams')
->will($this->returnValue(array())); ->will($this->returnValue(array()));
$configuration = $this->getMock('Alchemy\BinaryDriver\ConfigurationInterface'); $configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock();
$driver->expects($this->any()) $driver->expects($this->any())
->method('getConfiguration') ->method('getConfiguration')
->will($this->returnValue($configuration)); ->will($this->returnValue($configuration));
$failure = new ExecutionFailureException('failed to encode'); $failure = new RuntimeException('failed to encode');
$driver->expects($this->once()) $driver->expects($this->once())
->method('command') ->method('command')
->will($this->throwException($failure)); ->will($this->throwException($failure));
$video = new Video(__FILE__, $driver, $ffprobe); $video = new Video(__FILE__, $driver, $ffprobe);
$this->setExpectedException('FFMpeg\Exception\RuntimeException'); $this->expectException('\FFMpeg\Exception\RuntimeException');
$video->save($format, $outputPathfile); $video->save($format, $outputPathfile);
} }
@ -108,7 +109,7 @@ class VideoTest extends AbstractStreamableTestCase
$driver = $this->getFFMpegDriverMock(); $driver = $this->getFFMpegDriverMock();
$ffprobe = $this->getFFProbeMock(); $ffprobe = $this->getFFProbeMock();
$outputPathfile = '/target/file'; $outputPathfile = '/target/file';
$format = $this->getMock('FFMpeg\Format\VideoInterface'); $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$format->expects($this->any()) $format->expects($this->any())
->method('getExtraParams') ->method('getExtraParams')
->will($this->returnValue(array())); ->will($this->returnValue(array()));
@ -116,7 +117,7 @@ class VideoTest extends AbstractStreamableTestCase
->method('getPasses') ->method('getPasses')
->will($this->returnValue(2)); ->will($this->returnValue(2));
$configuration = $this->getMock('Alchemy\BinaryDriver\ConfigurationInterface'); $configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock();
$driver->expects($this->any()) $driver->expects($this->any())
->method('getConfiguration') ->method('getConfiguration')
@ -124,7 +125,7 @@ class VideoTest extends AbstractStreamableTestCase
$video = new Video(__FILE__, $driver, $ffprobe); $video = new Video(__FILE__, $driver, $ffprobe);
$filter = $this->getMock('FFMpeg\Filters\Video\VideoFilterInterface'); $filter = $this->getMockBuilder('FFMpeg\Filters\Video\VideoFilterInterface')->getMock();
$filter->expects($this->once()) $filter->expects($this->once())
->method('apply') ->method('apply')
->with($video, $format) ->with($video, $format)
@ -158,7 +159,7 @@ class VideoTest extends AbstractStreamableTestCase
$driver = $this->getFFMpegDriverMock(); $driver = $this->getFFMpegDriverMock();
$ffprobe = $this->getFFProbeMock(); $ffprobe = $this->getFFProbeMock();
$configuration = $this->getMock('Alchemy\BinaryDriver\ConfigurationInterface'); $configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock();
$driver->expects($this->any()) $driver->expects($this->any())
->method('getConfiguration') ->method('getConfiguration')
@ -233,7 +234,7 @@ class VideoTest extends AbstractStreamableTestCase
public function provideSaveData() public function provideSaveData()
{ {
$format = $this->getMock('FFMpeg\Format\VideoInterface'); $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$format->expects($this->any()) $format->expects($this->any())
->method('getExtraParams') ->method('getExtraParams')
->will($this->returnValue(array())); ->will($this->returnValue(array()));
@ -253,7 +254,7 @@ class VideoTest extends AbstractStreamableTestCase
->method('getAdditionalParameters') ->method('getAdditionalParameters')
->will($this->returnValue(array('foo', 'bar'))); ->will($this->returnValue(array('foo', 'bar')));
$format2 = $this->getMock('FFMpeg\Format\VideoInterface'); $format2 = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$format2->expects($this->any()) $format2->expects($this->any())
->method('getExtraParams') ->method('getExtraParams')
->will($this->returnValue(array())); ->will($this->returnValue(array()));
@ -273,7 +274,7 @@ class VideoTest extends AbstractStreamableTestCase
->method('getAdditionalParameters') ->method('getAdditionalParameters')
->will($this->returnValue(array('foo', 'bar'))); ->will($this->returnValue(array('foo', 'bar')));
$audioFormat = $this->getMock('FFMpeg\Format\AudioInterface'); $audioFormat = $this->getMockBuilder('FFMpeg\Format\AudioInterface')->getMock();
$audioFormat->expects($this->any()) $audioFormat->expects($this->any())
->method('getExtraParams') ->method('getExtraParams')
->will($this->returnValue(array())); ->will($this->returnValue(array()));
@ -290,7 +291,7 @@ class VideoTest extends AbstractStreamableTestCase
->method('getPasses') ->method('getPasses')
->will($this->returnValue(1)); ->will($this->returnValue(1));
$audioVideoFormat = $this->getMock('FFMpeg\Format\VideoInterface'); $audioVideoFormat = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$audioVideoFormat->expects($this->any()) $audioVideoFormat->expects($this->any())
->method('getExtraParams') ->method('getExtraParams')
->will($this->returnValue(array())); ->will($this->returnValue(array()));
@ -316,7 +317,7 @@ class VideoTest extends AbstractStreamableTestCase
->method('getAdditionalParameters') ->method('getAdditionalParameters')
->will($this->returnValue(array())); ->will($this->returnValue(array()));
$audioVideoFormatSinglePass = $this->getMock('FFMpeg\Format\VideoInterface'); $audioVideoFormatSinglePass = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$audioVideoFormatSinglePass->expects($this->any()) $audioVideoFormatSinglePass->expects($this->any())
->method('getExtraParams') ->method('getExtraParams')
->will($this->returnValue(array())); ->will($this->returnValue(array()));
@ -342,7 +343,7 @@ class VideoTest extends AbstractStreamableTestCase
->method('getAdditionalParameters') ->method('getAdditionalParameters')
->will($this->returnValue(array())); ->will($this->returnValue(array()));
$formatExtra = $this->getMock('FFMpeg\Format\VideoInterface'); $formatExtra = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$formatExtra->expects($this->any()) $formatExtra->expects($this->any())
->method('getExtraParams') ->method('getExtraParams')
->will($this->returnValue(array('extra', 'param'))); ->will($this->returnValue(array('extra', 'param')));
@ -362,7 +363,7 @@ class VideoTest extends AbstractStreamableTestCase
->method('getAdditionalParameters') ->method('getAdditionalParameters')
->will($this->returnValue(array())); ->will($this->returnValue(array()));
$formatExtra2 = $this->getMock('FFMpeg\Format\VideoInterface'); $formatExtra2 = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$formatExtra2->expects($this->any()) $formatExtra2->expects($this->any())
->method('getExtraParams') ->method('getExtraParams')
->will($this->returnValue(array('extra', 'param'))); ->will($this->returnValue(array('extra', 'param')));
@ -382,7 +383,7 @@ class VideoTest extends AbstractStreamableTestCase
->method('getAdditionalParameters') ->method('getAdditionalParameters')
->will($this->returnValue(array())); ->will($this->returnValue(array()));
$listeners = array($this->getMock('Alchemy\BinaryDriver\Listeners\ListenerInterface')); $listeners = array($this->getMockBuilder('Alchemy\BinaryDriver\Listeners\ListenerInterface')->getMock());
$progressableFormat = $this->getMockBuilder('Tests\FFMpeg\Unit\Media\Prog') $progressableFormat = $this->getMockBuilder('Tests\FFMpeg\Unit\Media\Prog')
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
@ -585,7 +586,7 @@ class VideoTest extends AbstractStreamableTestCase
$driver = $this->getFFMpegDriverMock(); $driver = $this->getFFMpegDriverMock();
$ffprobe = $this->getFFProbeMock(); $ffprobe = $this->getFFProbeMock();
$configuration = $this->getMock('Alchemy\BinaryDriver\ConfigurationInterface'); $configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock();
$driver->expects($this->any()) $driver->expects($this->any())
->method('getConfiguration') ->method('getConfiguration')
@ -612,7 +613,7 @@ class VideoTest extends AbstractStreamableTestCase
$outputPathfile = '/target/file'; $outputPathfile = '/target/file';
$format = $this->getMock('FFMpeg\Format\VideoInterface'); $format = $this->getMockBuilder('FFMpeg\Format\VideoInterface')->getMock();
$format->expects($this->any()) $format->expects($this->any())
->method('getExtraParams') ->method('getExtraParams')
->will($this->returnValue(array('param'))); ->will($this->returnValue(array('param')));

View file

@ -25,7 +25,7 @@ class WaveformTest extends AbstractMediaTestCase
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$filter = $this->getMock('FFMpeg\Filters\Waveform\WaveformFilterInterface'); $filter = $this->getMockBuilder('FFMpeg\Filters\Waveform\WaveformFilterInterface')->getMock();
$filters->expects($this->once()) $filters->expects($this->once())
->method('add') ->method('add')

View file

@ -2,23 +2,18 @@
namespace Tests\FFMpeg\Unit; namespace Tests\FFMpeg\Unit;
use PHPUnit\Framework\TestCase as BaseTestCase; use Tests\FFMpeg\BaseTestCase;
class TestCase extends BaseTestCase class TestCase extends BaseTestCase
{ {
public function assertScalar($value)
{
$this->assertTrue(is_scalar($value));
}
public function getLoggerMock() public function getLoggerMock()
{ {
return $this->getMock('Psr\Log\LoggerInterface'); return $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
} }
public function getCacheMock() public function getCacheMock()
{ {
return $this->getMock('Doctrine\Common\Cache\Cache'); return $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
} }
public function getTimeCodeMock() public function getTimeCodeMock()
@ -86,17 +81,17 @@ class TestCase extends BaseTestCase
public function getFFProbeParserMock() public function getFFProbeParserMock()
{ {
return $this->getMock('FFMpeg\FFProbe\OutputParserInterface'); return $this->getMockBuilder('FFMpeg\FFProbe\OutputParserInterface')->getMock();
} }
public function getFFProbeOptionsTesterMock() public function getFFProbeOptionsTesterMock()
{ {
return $this->getMock('FFMpeg\FFProbe\OptionsTesterInterface'); return $this->getMockBuilder('FFMpeg\FFProbe\OptionsTesterInterface')->getMock();
} }
public function getFFProbeMapperMock() public function getFFProbeMapperMock()
{ {
return $this->getMock('FFMpeg\FFProbe\MapperInterface'); return $this->getMockBuilder('FFMpeg\FFProbe\MapperInterface')->getMock();
} }
public function getFFProbeOptionsTesterMockWithOptions(array $options) public function getFFProbeOptionsTesterMockWithOptions(array $options)
@ -114,7 +109,7 @@ class TestCase extends BaseTestCase
public function getConfigurationMock() public function getConfigurationMock()
{ {
return $this->getMock('Alchemy\BinaryDriver\ConfigurationInterface'); return $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock();
} }
public function getFormatMock() public function getFormatMock()