Fix PhpUnit tests for newer php version
This commit is contained in:
parent
537f61095f
commit
14dc6a8b1b
21 changed files with 48 additions and 40 deletions
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@ class TimeCodeTest extends TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException FFMpeg\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function testFromInvalidString()
|
||||
{
|
||||
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
|
||||
TimeCode::fromString('lalali lala');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue