Add bc layer for older php and phpunit versions
This commit is contained in:
parent
8837f4b115
commit
7474bf936f
16 changed files with 90 additions and 99 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -8,3 +8,4 @@ phpunit.xml
|
||||||
/tests/Functional/output/output-*
|
/tests/Functional/output/output-*
|
||||||
sami.phar
|
sami.phar
|
||||||
.idea/
|
.idea/
|
||||||
|
/phpunit
|
||||||
|
|
|
||||||
24
.travis.yml
24
.travis.yml
|
|
@ -16,9 +16,14 @@ matrix:
|
||||||
include:
|
include:
|
||||||
- php: 5.4
|
- php: 5.4
|
||||||
env:
|
env:
|
||||||
|
- PHPUNIT_VERSION=4
|
||||||
- COMPOSER_FLAGS="--prefer-lowest"
|
- COMPOSER_FLAGS="--prefer-lowest"
|
||||||
- php: 5.4
|
- php: 5.4
|
||||||
|
env:
|
||||||
|
- PHPUNIT_VERSION=4
|
||||||
- php: 5.5
|
- php: 5.5
|
||||||
|
env:
|
||||||
|
- PHPUNIT_VERSION=4
|
||||||
- php: 5.6
|
- php: 5.6
|
||||||
- php: 7.0
|
- php: 7.0
|
||||||
- php: 7.1
|
- php: 7.1
|
||||||
|
|
@ -30,11 +35,26 @@ 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;
|
||||||
|
|
|
||||||
|
|
@ -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 || ^5.0 || ^6.0 || ^7.0"
|
"symfony/phpunit-bridge": "^5.0.4"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": {
|
"psr-0": {
|
||||||
|
|
|
||||||
|
|
@ -4,57 +4,49 @@ namespace Tests\FFMpeg;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class BaseTestCase extends TestCase
|
/**
|
||||||
{
|
* This is a BC Layer to support phpunit 4.8 needed for php <= 5.5.
|
||||||
public function assertScalar($value, $message = '')
|
*/
|
||||||
|
if (class_exists('PHPUnit_Runner_Version')
|
||||||
|
&& version_compare(\PHPUnit_Runner_Version::id(), '5', '<')) {
|
||||||
|
class BaseTestCase extends TestCase
|
||||||
{
|
{
|
||||||
$this->assertTrue(is_scalar($value), $message);
|
public static function assertScalar($value, $message = '')
|
||||||
}
|
{
|
||||||
|
self::assertTrue(is_scalar($value), $message);
|
||||||
/**
|
|
||||||
* Can be removed when phpunit 4.8 (<= needed for php 5.5) support is removed.
|
|
||||||
*/
|
|
||||||
public function assertIsArray($value, $message = '')
|
|
||||||
{
|
|
||||||
$this->assertTrue(is_array($value), $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Can be removed when phpunit 4.8 (<= needed for php 5.5) support is removed.
|
|
||||||
*/
|
|
||||||
public function assertIsInt($value, $message = '')
|
|
||||||
{
|
|
||||||
$this->assertTrue(is_int($value), $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Can be removed when phpunit 4.8 (<= needed for php 5.5) support is removed.
|
|
||||||
*/
|
|
||||||
public function assertIsBool($value, $message = '')
|
|
||||||
{
|
|
||||||
$this->assertTrue(is_bool($value), $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Can be removed when phpunit 4.8 (<= needed for php 5.5) support is removed.
|
|
||||||
*/
|
|
||||||
public function assertIsString($value, $message = '')
|
|
||||||
{
|
|
||||||
$this->assertTrue(is_string($value), $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Can be removed when phpunit 4.8 (<= needed for php 5.5) support is removed.
|
|
||||||
*/
|
|
||||||
public function expectException($exception)
|
|
||||||
{
|
|
||||||
// PHPUnt BC Layer
|
|
||||||
if (method_exists(get_parent_class(), 'expectException')) {
|
|
||||||
parent::expectException($exception);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setExpectedException($exception);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,6 @@ class TimeCodeTest extends TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public function testFromInvalidString()
|
public function testFromInvalidString()
|
||||||
{
|
{
|
||||||
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,6 @@ class FFMpegDriverTest extends TestCase
|
||||||
$this->assertEquals($conf, $ffmpeg->getConfiguration());
|
$this->assertEquals($conf, $ffmpeg->getConfiguration());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public function testCreateFailureThrowsAnException()
|
public function testCreateFailureThrowsAnException()
|
||||||
{
|
{
|
||||||
$this->expectException('\FFMpeg\Exception\ExecutableNotFoundException');
|
$this->expectException('\FFMpeg\Exception\ExecutableNotFoundException');
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,6 @@ class FFProbeDriverTest extends TestCase
|
||||||
$this->assertEquals($conf, $ffprobe->getConfiguration());
|
$this->assertEquals($conf, $ffprobe->getConfiguration());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public function testCreateFailureThrowsAnException()
|
public function testCreateFailureThrowsAnException()
|
||||||
{
|
{
|
||||||
$this->expectException('\FFMpeg\Exception\ExecutableNotFoundException');
|
$this->expectException('\FFMpeg\Exception\ExecutableNotFoundException');
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,12 @@ use FFMpeg\FFProbe\DataMapping\Stream;
|
||||||
|
|
||||||
class FFMpegTest extends TestCase
|
class FFMpegTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @expectedExceptionMessage Unable to probe "/path/to/unknown/file".
|
|
||||||
*/
|
|
||||||
public function testOpenInvalid()
|
public function testOpenInvalid()
|
||||||
{
|
{
|
||||||
$this->expectException('\FFMpeg\Exception\RuntimeException');
|
$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,8 +57,6 @@ class FFMpegTest extends TestCase
|
||||||
$this->assertInstanceOf('FFMpeg\Media\Video', $ffmpeg->open(__FILE__));
|
$this->assertInstanceOf('FFMpeg\Media\Video', $ffmpeg->open(__FILE__));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public function testOpenUnknown()
|
public function testOpenUnknown()
|
||||||
{
|
{
|
||||||
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
||||||
|
|
|
||||||
|
|
@ -42,12 +42,12 @@ class StreamTest extends TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedExceptionMessage Dimensions can only be retrieved from video streams.
|
|
||||||
*/
|
|
||||||
public function testGetDimensionsFromAudio()
|
public function testGetDimensionsFromAudio()
|
||||||
{
|
{
|
||||||
$this->expectException('\FFMpeg\Exception\LogicException');
|
$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
|
||||||
* @expectedExceptionMessage Unable to extract dimensions.
|
|
||||||
*/
|
*/
|
||||||
public function testUnableToGetDimensionsFromVideo($properties)
|
public function testUnableToGetDimensionsFromVideo($properties)
|
||||||
{
|
{
|
||||||
$this->expectException('\FFMpeg\Exception\RuntimeException');
|
$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();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,6 @@ class MapperTest extends TestCase
|
||||||
$this->assertEquals($expected, $mapper->map($type, $data));
|
$this->assertEquals($expected, $mapper->map($type, $data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public function testMapInvalidArgument()
|
public function testMapInvalidArgument()
|
||||||
{
|
{
|
||||||
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
||||||
|
|
|
||||||
|
|
@ -2,26 +2,28 @@
|
||||||
|
|
||||||
namespace Tests\FFMpeg\Unit\FFProbe;
|
namespace Tests\FFMpeg\Unit\FFProbe;
|
||||||
|
|
||||||
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
|
|
||||||
use FFMpeg\Exception\RuntimeException;
|
|
||||||
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
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @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');
|
$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 RuntimeException('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');
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,6 @@ class OutputParserTest extends TestCase
|
||||||
$this->assertEquals($expectedOutput, $parser->parse($type, $data));
|
$this->assertEquals($expectedOutput, $parser->parse($type, $data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public function testParseWithInvalidArgument()
|
public function testParseWithInvalidArgument()
|
||||||
{
|
{
|
||||||
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
||||||
|
|
|
||||||
|
|
@ -64,8 +64,6 @@ class ExtractMultipleFramesFilterTest extends TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public function testInvalidFrameFileType() {
|
public function testInvalidFrameFileType() {
|
||||||
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
||||||
$filter = new ExtractMultipleFramesFilter('1/1', '/');
|
$filter = new ExtractMultipleFramesFilter('1/1', '/');
|
||||||
|
|
|
||||||
|
|
@ -61,12 +61,12 @@ class RotateFilterTest extends TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedExceptionMessage Invalid angle value.
|
|
||||||
*/
|
|
||||||
public function testApplyInvalidAngle()
|
public function testApplyInvalidAngle()
|
||||||
{
|
{
|
||||||
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
$this->expectException(
|
||||||
|
'\FFMpeg\Exception\InvalidArgumentException',
|
||||||
|
'Invalid angle value.'
|
||||||
|
);
|
||||||
new RotateFilter('90');
|
new RotateFilter('90');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,6 @@ abstract class AudioTestCase extends TestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public function testSetInvalidAudioCodec()
|
public function testSetInvalidAudioCodec()
|
||||||
{
|
{
|
||||||
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
||||||
|
|
@ -59,16 +57,12 @@ abstract class AudioTestCase extends TestCase
|
||||||
$this->assertEquals(256, $format->getAudioKiloBitrate());
|
$this->assertEquals(256, $format->getAudioKiloBitrate());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public function testSetInvalidKiloBitrate()
|
public function testSetInvalidKiloBitrate()
|
||||||
{
|
{
|
||||||
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
||||||
$this->getFormat()->setAudioKiloBitrate(0);
|
$this->getFormat()->setAudioKiloBitrate(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public function testSetNegativeKiloBitrate()
|
public function testSetNegativeKiloBitrate()
|
||||||
{
|
{
|
||||||
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
||||||
|
|
@ -87,16 +81,12 @@ abstract class AudioTestCase extends TestCase
|
||||||
$this->assertEquals(2, $format->getAudioChannels());
|
$this->assertEquals(2, $format->getAudioChannels());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public function testSetInvalidChannels()
|
public function testSetInvalidChannels()
|
||||||
{
|
{
|
||||||
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
||||||
$this->getFormat()->setAudioChannels(0);
|
$this->getFormat()->setAudioChannels(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public function testSetNegativeChannels()
|
public function testSetNegativeChannels()
|
||||||
{
|
{
|
||||||
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,6 @@ abstract class VideoTestCase extends AudioTestCase
|
||||||
$this->assertEquals(2560, $format->getKiloBitrate());
|
$this->assertEquals(2560, $format->getKiloBitrate());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public function testSetInvalidVideoCodec()
|
public function testSetInvalidVideoCodec()
|
||||||
{
|
{
|
||||||
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue