diff --git a/.gitignore b/.gitignore index 19696cf..997ac01 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ composer.phar composer.lock phpunit.xml .phpunit.result.cache +/tests/Functional/output/output-* sami.phar .idea/ diff --git a/src/FFMpeg/Media/Concat.php b/src/FFMpeg/Media/Concat.php index 092e3a3..29126fd 100644 --- a/src/FFMpeg/Media/Concat.php +++ b/src/FFMpeg/Media/Concat.php @@ -94,7 +94,7 @@ class Concat extends AbstractMediaType $fileStream = @fopen($sourcesFile, 'w'); if($fileStream === false) { - throw new ExecutionFailureException('Cannot open the temporary file.'); + throw new RuntimeException('Cannot open the temporary file.'); } $count_videos = 0; diff --git a/tests/Functional/VideoTranscodeTest.php b/tests/Functional/VideoTranscodeTest.php index 1bae7ed..bc5dfe0 100644 --- a/tests/Functional/VideoTranscodeTest.php +++ b/tests/Functional/VideoTranscodeTest.php @@ -71,10 +71,10 @@ class VideoTranscodeTest extends FunctionalTestCase } /** - * @expectedException \FFMpeg\Exception\RuntimeException */ public function testTranscodeInvalidFile() { + $this->expectException('\FFMpeg\Exception\RuntimeException'); $ffmpeg = $this->getFFMpeg(); $ffmpeg->open(__DIR__ . '/../files/UnknownFileTest.ogv'); } @@ -84,7 +84,7 @@ class VideoTranscodeTest extends FunctionalTestCase $ffmpeg = $this->getFFMpeg(); $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'); } diff --git a/tests/Unit/Coordinate/DimensionTest.php b/tests/Unit/Coordinate/DimensionTest.php index eed0c80..13854fc 100644 --- a/tests/Unit/Coordinate/DimensionTest.php +++ b/tests/Unit/Coordinate/DimensionTest.php @@ -9,10 +9,10 @@ class DimensionTest extends TestCase { /** * @dataProvider provideInvalidDimensions - * @expectedException FFMpeg\Exception\InvalidArgumentException */ public function testInvalidDimensions($width, $height) { + $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); new Dimension($width, $height); } diff --git a/tests/Unit/Coordinate/FrameRateTest.php b/tests/Unit/Coordinate/FrameRateTest.php index 60bf98a..da561c8 100644 --- a/tests/Unit/Coordinate/FrameRateTest.php +++ b/tests/Unit/Coordinate/FrameRateTest.php @@ -15,10 +15,10 @@ class FrameRateTest extends TestCase /** * @dataProvider provideInvalidFrameRates - * @expectedException FFMpeg\Exception\InvalidArgumentException */ public function testInvalidFrameRate($value) { + $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); new FrameRate($value); } diff --git a/tests/Unit/Coordinate/TimeCodeTest.php b/tests/Unit/Coordinate/TimeCodeTest.php index 08a6397..4101774 100644 --- a/tests/Unit/Coordinate/TimeCodeTest.php +++ b/tests/Unit/Coordinate/TimeCodeTest.php @@ -29,10 +29,10 @@ class TimeCodeTest extends TestCase } /** - * @expectedException FFMpeg\Exception\InvalidArgumentException */ public function testFromInvalidString() { + $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); TimeCode::fromString('lalali lala'); } diff --git a/tests/Unit/Driver/FFMpegDriverTest.php b/tests/Unit/Driver/FFMpegDriverTest.php index 7261fe3..b04d185 100644 --- a/tests/Unit/Driver/FFMpegDriverTest.php +++ b/tests/Unit/Driver/FFMpegDriverTest.php @@ -42,10 +42,10 @@ class FFMpegDriverTest extends TestCase } /** - * @expectedException FFMpeg\Exception\ExecutableNotFoundException */ public function testCreateFailureThrowsAnException() { + $this->expectException('\FFMpeg\Exception\ExecutableNotFoundException'); FFMpegDriver::create($this->getLoggerMock(), array('ffmpeg.binaries' => '/path/to/nowhere')); } } diff --git a/tests/Unit/Driver/FFProbeDriverTest.php b/tests/Unit/Driver/FFProbeDriverTest.php index e430491..8de13f3 100644 --- a/tests/Unit/Driver/FFProbeDriverTest.php +++ b/tests/Unit/Driver/FFProbeDriverTest.php @@ -42,10 +42,10 @@ class FFProbeDriverTest extends TestCase } /** - * @expectedException FFMpeg\Exception\ExecutableNotFoundException */ public function testCreateFailureThrowsAnException() { + $this->expectException('\FFMpeg\Exception\ExecutableNotFoundException'); FFProbeDriver::create(array('ffprobe.binaries' => '/path/to/nowhere')); } } diff --git a/tests/Unit/FFMpegServiceProviderTest.php b/tests/Unit/FFMpegServiceProviderTest.php index 66a4004..d690480 100644 --- a/tests/Unit/FFMpegServiceProviderTest.php +++ b/tests/Unit/FFMpegServiceProviderTest.php @@ -51,7 +51,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']; } @@ -64,7 +64,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']; } } diff --git a/tests/Unit/FFMpegTest.php b/tests/Unit/FFMpegTest.php index 53b0b72..d1a92a1 100644 --- a/tests/Unit/FFMpegTest.php +++ b/tests/Unit/FFMpegTest.php @@ -9,11 +9,11 @@ use FFMpeg\FFProbe\DataMapping\Stream; class FFMpegTest extends TestCase { /** - * @expectedException \FFMpeg\Exception\RuntimeException * @expectedExceptionMessage Unable to probe "/path/to/unknown/file". */ public function testOpenInvalid() { + $this->expectException('\FFMpeg\Exception\RuntimeException'); $ffmpeg = new FFMpeg($this->getFFMpegDriverMock(), $this->getFFProbeMock()); $ffmpeg->open('/path/to/unknown/file'); } @@ -58,10 +58,10 @@ class FFMpegTest extends TestCase } /** - * @expectedException \FFMpeg\Exception\InvalidArgumentException */ public function testOpenUnknown() { + $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); $ffprobe = $this->getFFProbeMock(); $ffprobe->expects($this->once()) ->method('streams') diff --git a/tests/Unit/FFProbe/DataMapping/StreamTest.php b/tests/Unit/FFProbe/DataMapping/StreamTest.php index 8fa8aec..0c1ec62 100644 --- a/tests/Unit/FFProbe/DataMapping/StreamTest.php +++ b/tests/Unit/FFProbe/DataMapping/StreamTest.php @@ -43,11 +43,11 @@ class StreamTest extends TestCase } /** - * @expectedException FFMpeg\Exception\LogicException * @expectedExceptionMessage Dimensions can only be retrieved from video streams. */ public function testGetDimensionsFromAudio() { + $this->expectException('\FFMpeg\Exception\LogicException'); $stream = new Stream(array('codec_type' => 'audio')); $stream->getDimensions(); } @@ -60,11 +60,11 @@ class StreamTest extends TestCase /** * @dataProvider provideInvalidPropertiesForDimensionsExtraction - * @expectedException FFMpeg\Exception\RuntimeException * @expectedExceptionMessage Unable to extract dimensions. */ public function testUnableToGetDimensionsFromVideo($properties) { + $this->expectException('\FFMpeg\Exception\RuntimeException'); $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 d4904a1..e765f39 100644 --- a/tests/Unit/FFProbe/MapperTest.php +++ b/tests/Unit/FFProbe/MapperTest.php @@ -21,10 +21,10 @@ class MapperTest extends TestCase } /** - * @expectedException FFMpeg\Exception\InvalidArgumentException */ public function testMapInvalidArgument() { + $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); $mapper = new Mapper(); $mapper->map('cool type', 'data'); } diff --git a/tests/Unit/FFProbe/OptionsTesterTest.php b/tests/Unit/FFProbe/OptionsTesterTest.php index 4f4ef56..ee8df5d 100644 --- a/tests/Unit/FFProbe/OptionsTesterTest.php +++ b/tests/Unit/FFProbe/OptionsTesterTest.php @@ -3,24 +3,25 @@ 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 { /** - * @expectedException FFMpeg\Exception\RuntimeException * @expectedExceptionMessage Your FFProbe version is too old and does not support `-help` option, please upgrade. */ public function testHasOptionWithOldFFProbe() { + $this->expectException('\FFMpeg\Exception\RuntimeException'); $cache = $this->getCacheMock(); $ffprobe = $this->getFFProbeDriverMock(); $ffprobe->expects($this->once()) ->method('command') ->with(array('-help', '-loglevel', 'quiet')) - ->will($this->throwException(new ExecutionFailureException('Failed to execute'))); + ->will($this->throwException(new RuntimeException('Failed to execute'))); $tester = new OptionsTester($ffprobe, $cache); $tester->has('-print_format'); diff --git a/tests/Unit/FFProbe/OutputParserTest.php b/tests/Unit/FFProbe/OutputParserTest.php index e09916d..aa5c36d 100644 --- a/tests/Unit/FFProbe/OutputParserTest.php +++ b/tests/Unit/FFProbe/OutputParserTest.php @@ -18,10 +18,10 @@ class OutputParserTest extends TestCase } /** - * @expectedException FFMpeg\Exception\InvalidArgumentException */ public function testParseWithInvalidArgument() { + $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); $parser = new OutputParser(); $parser->parse('comme ca', 'data'); } diff --git a/tests/Unit/FFProbeTest.php b/tests/Unit/FFProbeTest.php index 4530f59..d927ab9 100644 --- a/tests/Unit/FFProbeTest.php +++ b/tests/Unit/FFProbeTest.php @@ -236,11 +236,11 @@ class FFProbeTest extends TestCase } /** - * @expectedException FFMpeg\Exception\RuntimeException * @dataProvider provideProbeMethod */ public function testProbeWithoutShowStreamsAvailable($method) { + $this->expectException('\FFMpeg\Exception\RuntimeException'); $pathfile = __FILE__; $ffprobe = new FFProbe($this->getFFProbeDriverMock(), $this->getCacheMock()); diff --git a/tests/Unit/Filters/Video/ExtractMultipleFramesFilterTest.php b/tests/Unit/Filters/Video/ExtractMultipleFramesFilterTest.php index eeb14b6..3a1873d 100644 --- a/tests/Unit/Filters/Video/ExtractMultipleFramesFilterTest.php +++ b/tests/Unit/Filters/Video/ExtractMultipleFramesFilterTest.php @@ -65,9 +65,9 @@ class ExtractMultipleFramesFilterTest extends TestCase } /** - * @expectedException \FFMpeg\Exception\InvalidArgumentException */ public function testInvalidFrameFileType() { + $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); $filter = new ExtractMultipleFramesFilter('1/1', '/'); $filter->setFrameFileType('webm'); } diff --git a/tests/Unit/Filters/Video/RotateFilterTest.php b/tests/Unit/Filters/Video/RotateFilterTest.php index 5d90433..78bba60 100644 --- a/tests/Unit/Filters/Video/RotateFilterTest.php +++ b/tests/Unit/Filters/Video/RotateFilterTest.php @@ -62,11 +62,11 @@ class RotateFilterTest extends TestCase } /** - * @expectedException \FFMpeg\Exception\InvalidArgumentException * @expectedExceptionMessage Invalid angle value. */ public function testApplyInvalidAngle() { + $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); new RotateFilter('90'); } } diff --git a/tests/Unit/Format/Audio/AudioTestCase.php b/tests/Unit/Format/Audio/AudioTestCase.php index 8cc9574..ce1fbc7 100644 --- a/tests/Unit/Format/Audio/AudioTestCase.php +++ b/tests/Unit/Format/Audio/AudioTestCase.php @@ -9,7 +9,11 @@ abstract class AudioTestCase extends TestCase { public function testExtraParams() { - foreach ($this->getFormat()->getExtraParams() as $param) { + $extraParams = $this->getFormat()->getExtraParams(); + + $this->assertIsArray($extraParams); + + foreach ($extraParams as $param) { $this->assertScalar($param); } } @@ -31,10 +35,10 @@ abstract class AudioTestCase extends TestCase } /** - * @expectedException FFMpeg\Exception\InvalidArgumentException */ public function testSetInvalidAudioCodec() { + $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); $this->getFormat()->setAudioCodec('invalid-random-audio-codec'); } @@ -45,7 +49,7 @@ abstract class AudioTestCase extends TestCase public function testGetAudioKiloBitrate() { - $this->assertInternalType('integer', $this->getFormat()->getAudioKiloBitrate()); + $this->assertIsInt($this->getFormat()->getAudioKiloBitrate()); } public function testSetAudioKiloBitrate() @@ -56,24 +60,24 @@ abstract class AudioTestCase extends TestCase } /** - * @expectedException FFMpeg\Exception\InvalidArgumentException */ public function testSetInvalidKiloBitrate() { + $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); $this->getFormat()->setAudioKiloBitrate(0); } /** - * @expectedException FFMpeg\Exception\InvalidArgumentException */ public function testSetNegativeKiloBitrate() { + $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); $this->getFormat()->setAudioKiloBitrate(-10); } public function testGetAudioChannels() { - $this->assertInternalType('null', $this->getFormat()->getAudioChannels()); + $this->assertNull($this->getFormat()->getAudioChannels()); } public function testSetAudioChannels() @@ -84,18 +88,18 @@ abstract class AudioTestCase extends TestCase } /** - * @expectedException FFMpeg\Exception\InvalidArgumentException */ public function testSetInvalidChannels() { + $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); $this->getFormat()->setAudioChannels(0); } /** - * @expectedException FFMpeg\Exception\InvalidArgumentException */ public function testSetNegativeChannels() { + $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); $this->getFormat()->setAudioChannels(-10); } diff --git a/tests/Unit/Format/Video/VideoTestCase.php b/tests/Unit/Format/Video/VideoTestCase.php index 5e09344..d4eca24 100644 --- a/tests/Unit/Format/Video/VideoTestCase.php +++ b/tests/Unit/Format/Video/VideoTestCase.php @@ -14,7 +14,7 @@ abstract class VideoTestCase extends AudioTestCase public function testSupportBFrames() { - $this->assertInternalType('boolean', $this->getFormat()->supportBFrames()); + $this->assertIsBool($this->getFormat()->supportBFrames()); } public function testSetVideoCodec() @@ -29,7 +29,7 @@ abstract class VideoTestCase extends AudioTestCase public function testGetKiloBitrate() { - $this->assertInternalType('integer', $this->getFormat()->getKiloBitrate()); + $this->assertIsInt($this->getFormat()->getKiloBitrate()); } public function testSetKiloBitrate() @@ -40,10 +40,10 @@ abstract class VideoTestCase extends AudioTestCase } /** - * @expectedException FFMpeg\Exception\InvalidArgumentException */ public function testSetInvalidVideoCodec() { + $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); $this->getFormat()->setVideoCodec('invalid-random-video-codec'); } @@ -72,13 +72,13 @@ abstract class VideoTestCase extends AudioTestCase public function testGetPasses() { - $this->assertInternalType('integer', $this->getFormat()->getPasses()); + $this->assertIsInt($this->getFormat()->getPasses()); $this->assertGreaterThan(0, $this->getFormat()->getPasses()); } public function testGetModulus() { - $this->assertInternalType('integer', $this->getFormat()->getModulus()); + $this->assertIsInt($this->getFormat()->getModulus()); $this->assertGreaterThan(0, $this->getFormat()->getModulus()); $this->assertEquals(0, $this->getFormat()->getModulus() % 2); } diff --git a/tests/Unit/Media/AudioTest.php b/tests/Unit/Media/AudioTest.php index 873598c..ed4dadf 100644 --- a/tests/Unit/Media/AudioTest.php +++ b/tests/Unit/Media/AudioTest.php @@ -2,6 +2,7 @@ namespace Tests\FFMpeg\Unit\Media; +use FFMpeg\Exception\RuntimeException; use FFMpeg\Media\Audio; use Alchemy\BinaryDriver\Exception\ExecutionFailureException; use FFMpeg\Format\AudioInterface; @@ -55,7 +56,7 @@ class AudioTest extends AbstractStreamableTestCase $filters->expects($this->never()) ->method('add'); - $this->setExpectedException('FFMpeg\Exception\InvalidArgumentException'); + $this->expectException('\FFMpeg\Exception\InvalidArgumentException'); $audio->addFilter($filter); } @@ -70,19 +71,19 @@ class AudioTest extends AbstractStreamableTestCase ->method('getExtraParams') ->will($this->returnValue(array())); - $configuration = $this->getMock('Alchemy\BinaryDriver\ConfigurationInterface'); + $configuration = $this->getMockBuilder('Alchemy\BinaryDriver\ConfigurationInterface')->getMock(); $driver->expects($this->any()) ->method('getConfiguration') ->will($this->returnValue($configuration)); - $failure = new ExecutionFailureException('failed to encode'); + $failure = new RuntimeException('failed to encode'); $driver->expects($this->once()) ->method('command') ->will($this->throwException($failure)); $audio = new Audio(__FILE__, $driver, $ffprobe); - $this->setExpectedException('FFMpeg\Exception\RuntimeException'); + $this->expectException('\FFMpeg\Exception\RuntimeException'); $audio->save($format, $outputPathfile); } diff --git a/tests/Unit/Media/VideoTest.php b/tests/Unit/Media/VideoTest.php index 0347a4f..03c42de 100644 --- a/tests/Unit/Media/VideoTest.php +++ b/tests/Unit/Media/VideoTest.php @@ -2,6 +2,7 @@ namespace Tests\FFMpeg\Unit\Media; +use FFMpeg\Exception\RuntimeException; use FFMpeg\Media\Video; use Alchemy\BinaryDriver\Exception\ExecutionFailureException; use FFMpeg\Format\VideoInterface; @@ -93,13 +94,13 @@ class VideoTest extends AbstractStreamableTestCase ->method('getConfiguration') ->will($this->returnValue($configuration)); - $failure = new ExecutionFailureException('failed to encode'); + $failure = new RuntimeException('failed to encode'); $driver->expects($this->once()) ->method('command') ->will($this->throwException($failure)); $video = new Video(__FILE__, $driver, $ffprobe); - $this->setExpectedException('FFMpeg\Exception\RuntimeException'); + $this->expectException('\FFMpeg\Exception\RuntimeException'); $video->save($format, $outputPathfile); }