diff --git a/.gitignore b/.gitignore index 997ac01..6b443ed 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ phpunit.xml /tests/Functional/output/output-* sami.phar .idea/ +/phpunit diff --git a/.travis.yml b/.travis.yml index cf52955..0cdcf37 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,9 +16,14 @@ matrix: include: - php: 5.4 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 @@ -30,11 +35,26 @@ before_install: - sudo add-apt-repository ppa:mc3man/trusty-media -y - sudo apt-get update -q - 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: - sudo apt-get install -y ffmpeg - composer update --prefer-dist $COMPOSER_FLAGS script: - - vendor/bin/phpunit --verbose + - | + if [ "$PHPUNIT_VERSION" ]; then + ./phpunit --verbose + else + ./vendor/bin/simple-phpunit --verbose + fi; diff --git a/composer.json b/composer.json index ba61f03..fda1beb 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ "require-dev": { "sami/sami": "~1.0", "silex/silex": "~1.0", - "phpunit/phpunit": "^4.8.36 || ^5.0 || ^6.0 || ^7.0" + "symfony/phpunit-bridge": "^5.0.4" }, "autoload": { "psr-0": { diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php index 0af9d1b..75f8877 100644 --- a/tests/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -4,57 +4,49 @@ namespace Tests\FFMpeg; use PHPUnit\Framework\TestCase; -class BaseTestCase extends TestCase -{ - public function assertScalar($value, $message = '') +/** + * 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 { - $this->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; + public static function assertScalar($value, $message = '') + { + self::assertTrue(is_scalar($value), $message); } - $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); + } } } diff --git a/tests/Unit/Coordinate/TimeCodeTest.php b/tests/Unit/Coordinate/TimeCodeTest.php index 4101774..a91b366 100644 --- a/tests/Unit/Coordinate/TimeCodeTest.php +++ b/tests/Unit/Coordinate/TimeCodeTest.php @@ -28,8 +28,6 @@ class TimeCodeTest extends TestCase ); } - /** - */ public function testFromInvalidString() { $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); diff --git a/tests/Unit/Driver/FFMpegDriverTest.php b/tests/Unit/Driver/FFMpegDriverTest.php index b04d185..ec4acbd 100644 --- a/tests/Unit/Driver/FFMpegDriverTest.php +++ b/tests/Unit/Driver/FFMpegDriverTest.php @@ -41,8 +41,6 @@ class FFMpegDriverTest extends TestCase $this->assertEquals($conf, $ffmpeg->getConfiguration()); } - /** - */ public function testCreateFailureThrowsAnException() { $this->expectException('\FFMpeg\Exception\ExecutableNotFoundException'); diff --git a/tests/Unit/Driver/FFProbeDriverTest.php b/tests/Unit/Driver/FFProbeDriverTest.php index 8de13f3..d42074e 100644 --- a/tests/Unit/Driver/FFProbeDriverTest.php +++ b/tests/Unit/Driver/FFProbeDriverTest.php @@ -41,8 +41,6 @@ class FFProbeDriverTest extends TestCase $this->assertEquals($conf, $ffprobe->getConfiguration()); } - /** - */ public function testCreateFailureThrowsAnException() { $this->expectException('\FFMpeg\Exception\ExecutableNotFoundException'); diff --git a/tests/Unit/FFMpegTest.php b/tests/Unit/FFMpegTest.php index d1a92a1..08043d6 100644 --- a/tests/Unit/FFMpegTest.php +++ b/tests/Unit/FFMpegTest.php @@ -8,12 +8,12 @@ use FFMpeg\FFProbe\DataMapping\Stream; class FFMpegTest extends TestCase { - /** - * @expectedExceptionMessage Unable to probe "/path/to/unknown/file". - */ 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->open('/path/to/unknown/file'); } @@ -57,8 +57,6 @@ class FFMpegTest extends TestCase $this->assertInstanceOf('FFMpeg\Media\Video', $ffmpeg->open(__FILE__)); } - /** - */ public function testOpenUnknown() { $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); diff --git a/tests/Unit/FFProbe/DataMapping/StreamTest.php b/tests/Unit/FFProbe/DataMapping/StreamTest.php index 0c1ec62..0eaee6a 100644 --- a/tests/Unit/FFProbe/DataMapping/StreamTest.php +++ b/tests/Unit/FFProbe/DataMapping/StreamTest.php @@ -42,12 +42,12 @@ class StreamTest extends TestCase ); } - /** - * @expectedExceptionMessage Dimensions can only be retrieved from video streams. - */ 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->getDimensions(); } @@ -60,11 +60,13 @@ class StreamTest extends TestCase /** * @dataProvider provideInvalidPropertiesForDimensionsExtraction - * @expectedExceptionMessage Unable to extract dimensions. */ 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->getDimensions(); } diff --git a/tests/Unit/FFProbe/MapperTest.php b/tests/Unit/FFProbe/MapperTest.php index e765f39..2ed5360 100644 --- a/tests/Unit/FFProbe/MapperTest.php +++ b/tests/Unit/FFProbe/MapperTest.php @@ -20,8 +20,6 @@ class MapperTest extends TestCase $this->assertEquals($expected, $mapper->map($type, $data)); } - /** - */ public function testMapInvalidArgument() { $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); diff --git a/tests/Unit/FFProbe/OptionsTesterTest.php b/tests/Unit/FFProbe/OptionsTesterTest.php index ee8df5d..4436928 100644 --- a/tests/Unit/FFProbe/OptionsTesterTest.php +++ b/tests/Unit/FFProbe/OptionsTesterTest.php @@ -2,26 +2,28 @@ namespace Tests\FFMpeg\Unit\FFProbe; -use Alchemy\BinaryDriver\Exception\ExecutionFailureException; -use FFMpeg\Exception\RuntimeException; use Tests\FFMpeg\Unit\TestCase; use FFMpeg\FFProbe\OptionsTester; class OptionsTesterTest extends TestCase { - /** - * @expectedExceptionMessage Your FFProbe version is too old and does not support `-help` option, please upgrade. - */ 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(); + $executionFailerExceptionMock = $this->getMockBuilder('Alchemy\BinaryDriver\Exception\ExecutionFailureException') + ->disableOriginalConstructor() + ->getMock(); + $ffprobe = $this->getFFProbeDriverMock(); $ffprobe->expects($this->once()) ->method('command') ->with(array('-help', '-loglevel', 'quiet')) - ->will($this->throwException(new RuntimeException('Failed to execute'))); + ->will($this->throwException($executionFailerExceptionMock)); $tester = new OptionsTester($ffprobe, $cache); $tester->has('-print_format'); diff --git a/tests/Unit/FFProbe/OutputParserTest.php b/tests/Unit/FFProbe/OutputParserTest.php index aa5c36d..91b7160 100644 --- a/tests/Unit/FFProbe/OutputParserTest.php +++ b/tests/Unit/FFProbe/OutputParserTest.php @@ -17,8 +17,6 @@ class OutputParserTest extends TestCase $this->assertEquals($expectedOutput, $parser->parse($type, $data)); } - /** - */ public function testParseWithInvalidArgument() { $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); diff --git a/tests/Unit/Filters/Video/ExtractMultipleFramesFilterTest.php b/tests/Unit/Filters/Video/ExtractMultipleFramesFilterTest.php index 3a1873d..23981c2 100644 --- a/tests/Unit/Filters/Video/ExtractMultipleFramesFilterTest.php +++ b/tests/Unit/Filters/Video/ExtractMultipleFramesFilterTest.php @@ -64,8 +64,6 @@ class ExtractMultipleFramesFilterTest extends TestCase ); } - /** - */ public function testInvalidFrameFileType() { $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); $filter = new ExtractMultipleFramesFilter('1/1', '/'); diff --git a/tests/Unit/Filters/Video/RotateFilterTest.php b/tests/Unit/Filters/Video/RotateFilterTest.php index 78bba60..7aa956a 100644 --- a/tests/Unit/Filters/Video/RotateFilterTest.php +++ b/tests/Unit/Filters/Video/RotateFilterTest.php @@ -61,12 +61,12 @@ class RotateFilterTest extends TestCase ); } - /** - * @expectedExceptionMessage Invalid angle value. - */ public function testApplyInvalidAngle() { - $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); + $this->expectException( + '\FFMpeg\Exception\InvalidArgumentException', + 'Invalid angle value.' + ); new RotateFilter('90'); } } diff --git a/tests/Unit/Format/Audio/AudioTestCase.php b/tests/Unit/Format/Audio/AudioTestCase.php index ce1fbc7..79d02e3 100644 --- a/tests/Unit/Format/Audio/AudioTestCase.php +++ b/tests/Unit/Format/Audio/AudioTestCase.php @@ -34,8 +34,6 @@ abstract class AudioTestCase extends TestCase } } - /** - */ public function testSetInvalidAudioCodec() { $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); @@ -59,16 +57,12 @@ abstract class AudioTestCase extends TestCase $this->assertEquals(256, $format->getAudioKiloBitrate()); } - /** - */ public function testSetInvalidKiloBitrate() { $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); $this->getFormat()->setAudioKiloBitrate(0); } - /** - */ public function testSetNegativeKiloBitrate() { $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); @@ -87,16 +81,12 @@ abstract class AudioTestCase extends TestCase $this->assertEquals(2, $format->getAudioChannels()); } - /** - */ public function testSetInvalidChannels() { $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); $this->getFormat()->setAudioChannels(0); } - /** - */ public function testSetNegativeChannels() { $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); diff --git a/tests/Unit/Format/Video/VideoTestCase.php b/tests/Unit/Format/Video/VideoTestCase.php index d4eca24..0df42ee 100644 --- a/tests/Unit/Format/Video/VideoTestCase.php +++ b/tests/Unit/Format/Video/VideoTestCase.php @@ -39,8 +39,6 @@ abstract class VideoTestCase extends AudioTestCase $this->assertEquals(2560, $format->getKiloBitrate()); } - /** - */ public function testSetInvalidVideoCodec() { $this->expectException('\FFMpeg\Exception\InvalidArgumentException');