Add tests for FFMpeg and FFProbe
This commit is contained in:
parent
46992bfff6
commit
af18e54196
3 changed files with 112 additions and 68 deletions
BIN
tests/files/WrongFile.mp4
Normal file
BIN
tests/files/WrongFile.mp4
Normal file
Binary file not shown.
|
|
@ -10,28 +10,80 @@ class FFMpegTest extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
protected $object;
|
protected $object;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var FFProbe
|
||||||
|
*/
|
||||||
|
protected $probe;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->object = FFMpeg::load();
|
||||||
|
$this->probe = FFProbe::load();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers FFMpeg\FFMpeg::open
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function testOpenInvalid()
|
||||||
|
{
|
||||||
|
$this->object->open(__DIR__ . '/invalid.files');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FFMpeg\FFMpeg::open
|
* @covers FFMpeg\FFMpeg::open
|
||||||
* @todo Implement testOpen().
|
|
||||||
*/
|
*/
|
||||||
public function testOpen()
|
public function testOpen()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
$this->object->open(__DIR__ . '/../../files/Test.ogv');
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FFMpeg\FFMpeg::extractImage
|
* @covers FFMpeg\FFMpeg::extractImage
|
||||||
* @todo Implement testExtractImage().
|
|
||||||
*/
|
*/
|
||||||
public function testExtractImage()
|
public function testExtractImage()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
$dest = __DIR__ . '/../../files/extract_Test.jpg';
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
$this->object->open(__DIR__ . '/../../files/Test.ogv');
|
||||||
);
|
$this->object->extractImage(2, $dest, 200, 200);
|
||||||
|
|
||||||
|
$this->probe->probeFormat($dest);
|
||||||
|
|
||||||
|
unlink($dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers FFMpeg\FFMpeg::extractImage
|
||||||
|
* @expectedException \RuntimeException
|
||||||
|
*/
|
||||||
|
public function testExtractImageNoMovie()
|
||||||
|
{
|
||||||
|
$this->object->extractImage(2, 'Path', 200, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers FFMpeg\FFMpeg::encode
|
||||||
|
* @expectedException \RuntimeException
|
||||||
|
*/
|
||||||
|
public function testEncode()
|
||||||
|
{
|
||||||
|
$this->object->encode(new Format\WebM(32, 32), './invalid.file');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers FFMpeg\FFMpeg::encode
|
||||||
|
* @expectedException \RuntimeException
|
||||||
|
*/
|
||||||
|
public function testWrongBinary()
|
||||||
|
{
|
||||||
|
$logger = new \Monolog\Logger('test');
|
||||||
|
$logger->pushHandler(new \Monolog\Handler\NullHandler());
|
||||||
|
|
||||||
|
$ffmpeg = new FFMpeg('wrongbinary', $logger);
|
||||||
|
$ffmpeg->open(__DIR__ . '/../../files/Test.ogv');
|
||||||
|
$ffmpeg->encode(new Format\WebM(32, 32), './invalid.file');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -39,15 +91,12 @@ class FFMpegTest extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
public function testEncodeWebm()
|
public function testEncodeWebm()
|
||||||
{
|
{
|
||||||
$ffprobe = FFProbe::load();
|
|
||||||
|
|
||||||
$dest = __DIR__ . '/../../files/encode_test.webm';
|
$dest = __DIR__ . '/../../files/encode_test.webm';
|
||||||
|
|
||||||
$ffmpeg = FFMpeg::load(new \Monolog\Logger('test'));
|
$this->object->open(__DIR__ . '/../../files/Test.ogv');
|
||||||
$ffmpeg->open(__DIR__ . '/../../files/Test.ogv');
|
$this->object->encode(new Format\WebM(32, 32), $dest);
|
||||||
$ffmpeg->encode(new Format\WebM(32, 32), $dest);
|
|
||||||
|
|
||||||
$ffprobe->probeFormat($dest);
|
$this->probe->probeFormat($dest);
|
||||||
|
|
||||||
unlink($dest);
|
unlink($dest);
|
||||||
}
|
}
|
||||||
|
|
@ -57,15 +106,12 @@ class FFMpegTest extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
public function testEncodeOgg()
|
public function testEncodeOgg()
|
||||||
{
|
{
|
||||||
$ffprobe = FFProbe::load();
|
|
||||||
|
|
||||||
$dest = __DIR__ . '/../../files/encode_test.ogv';
|
$dest = __DIR__ . '/../../files/encode_test.ogv';
|
||||||
|
|
||||||
$ffmpeg = FFMpeg::load(new \Monolog\Logger('test'));
|
$this->object->open(__DIR__ . '/../../files/Test.ogv');
|
||||||
$ffmpeg->open(__DIR__ . '/../../files/Test.ogv');
|
$this->object->encode(new Format\Ogg(32, 32), $dest);
|
||||||
$ffmpeg->encode(new Format\Ogg(32, 32), $dest);
|
|
||||||
|
|
||||||
$ffprobe->probeFormat($dest);
|
$this->probe->probeFormat($dest);
|
||||||
|
|
||||||
unlink($dest);
|
unlink($dest);
|
||||||
}
|
}
|
||||||
|
|
@ -75,16 +121,12 @@ class FFMpegTest extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
public function testEncodeX264()
|
public function testEncodeX264()
|
||||||
{
|
{
|
||||||
|
|
||||||
$ffprobe = FFProbe::load();
|
|
||||||
|
|
||||||
$dest = __DIR__ . '/../../files/encode_test.mp4';
|
$dest = __DIR__ . '/../../files/encode_test.mp4';
|
||||||
|
|
||||||
$ffmpeg = FFMpeg::load(new \Monolog\Logger('test'));
|
$this->object->open(__DIR__ . '/../../files/Test.ogv');
|
||||||
$ffmpeg->open(__DIR__ . '/../../files/Test.ogv');
|
$this->object->encode(new Format\X264(32, 32), $dest);
|
||||||
$ffmpeg->encode(new Format\X264(32, 32), $dest);
|
|
||||||
|
|
||||||
$ffprobe->probeFormat($dest);
|
$this->probe->probeFormat($dest);
|
||||||
|
|
||||||
unlink($dest);
|
unlink($dest);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,63 +6,65 @@ class FFProbeTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FFMpeg\FFProbe::probeFormat
|
*
|
||||||
* @todo Implement testProbeFormat().
|
* @var FFProbe
|
||||||
*/
|
*/
|
||||||
public function testProbeFormat()
|
protected $object;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
$this->object = FFProbe::load();
|
||||||
$this->markTestIncomplete(
|
}
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
/**
|
||||||
|
* @covers FFMpeg\FFProbe::probeFormat
|
||||||
|
* @covers FFMpeg\FFProbe::probeStreams
|
||||||
|
* @covers FFMpeg\FFProbe::executeProbe
|
||||||
|
*/
|
||||||
|
public function testProbe()
|
||||||
|
{
|
||||||
|
$this->object->probeFormat(__DIR__ . '/../../files/Test.ogv');
|
||||||
|
$this->object->probeStreams(__DIR__ . '/../../files/Test.ogv');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers FFMpeg\FFProbe::probeFormat
|
||||||
|
* @covers FFMpeg\FFProbe::executeProbe
|
||||||
|
* @expectedException \RuntimeException
|
||||||
|
*/
|
||||||
|
public function testProbeInvalidFile()
|
||||||
|
{
|
||||||
|
$this->object->probeFormat(__DIR__ . '/../../files/WrongFile.mp4');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FFMpeg\FFProbe::probeStreams
|
* @covers FFMpeg\FFProbe::probeStreams
|
||||||
* @todo Implement testProbeStreams().
|
* @covers FFMpeg\FFProbe::executeProbe
|
||||||
|
* @expectedException \RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testProbeStreams()
|
public function testProbeStreamsInvalidFile()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
$this->object->probeStreams(__DIR__ . '/../../files/WrongFile.mp4');
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FFMpeg\FFProbe::probeFrames
|
* @covers FFMpeg\FFProbe::probeStreams
|
||||||
* @todo Implement testProbeFrames().
|
* @covers FFMpeg\FFProbe::executeProbe
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testProbeFrames()
|
public function testProbeStreamsInvalidPathFile()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
$this->object->probeStreams(__DIR__ . '/../../files/unknown.file');
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FFMpeg\FFProbe::probePackets
|
* @covers FFMpeg\FFProbe::probeFormat
|
||||||
* @todo Implement testProbePackets().
|
* @covers FFMpeg\FFProbe::executeProbe
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testProbePackets()
|
public function testProbeFormatInvalidPathFile()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
$this->object->probeFormat(__DIR__ . '/../../files/unknown.file');
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers FFMpeg\FFProbe::probeErrors
|
|
||||||
* @todo Implement testProbeErrors().
|
|
||||||
*/
|
|
||||||
public function testProbeErrors()
|
|
||||||
{
|
|
||||||
// Remove the following lines when you implement this test.
|
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue