ffmpeg-mappable-media/tests/FFMpeg/Unit/Format/Audio/AudioTestCase.php

119 lines
3.5 KiB
PHP
Raw Normal View History

2013-06-25 10:03:20 +02:00
<?php
namespace Tests\FFMpeg\Unit\Format\Audio;
2013-06-25 10:03:20 +02:00
use FFMpeg\Format\Audio\DefaultAudio;
use Tests\FFMpeg\Unit\TestCase;
2013-06-25 10:03:20 +02:00
abstract class AudioTestCase extends TestCase
{
public function testExtraParams()
{
$extraParams = $this->getFormat()->getExtraParams();
$this->assertIsArray($extraParams);
foreach ($extraParams as $param) {
2013-06-25 10:03:20 +02:00
$this->assertScalar($param);
}
}
public function testGetAudioCodec()
{
$this->assertScalar($this->getFormat()->getAudioCodec());
$this->assertContains($this->getFormat()->getAudioCodec(), $this->getFormat()->getAvailableAudioCodecs());
}
public function testSetAudioCodec()
{
$format = $this->getFormat();
foreach ($format->getAvailableAudioCodecs() as $codec) {
$format->setAudioCodec($codec);
$this->assertEquals($codec, $format->getAudioCodec());
}
}
public function testSetInvalidAudioCodec()
{
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
2013-06-25 10:03:20 +02:00
$this->getFormat()->setAudioCodec('invalid-random-audio-codec');
}
public function testGetAvailableAudioCodecs()
{
$this->assertGreaterThan(0, count($this->getFormat()->getAvailableAudioCodecs()));
}
public function testGetAudioKiloBitrate()
{
$this->assertIsInt($this->getFormat()->getAudioKiloBitrate());
2013-06-25 10:03:20 +02:00
}
public function testSetAudioKiloBitrate()
{
$format = $this->getFormat();
$format->setAudioKiloBitrate(256);
$this->assertEquals(256, $format->getAudioKiloBitrate());
}
public function testSetInvalidKiloBitrate()
{
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
2013-06-25 10:03:20 +02:00
$this->getFormat()->setAudioKiloBitrate(0);
}
public function testSetNegativeKiloBitrate()
{
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
2013-06-25 10:03:20 +02:00
$this->getFormat()->setAudioKiloBitrate(-10);
}
2014-06-25 09:55:00 +02:00
public function testGetAudioChannels()
{
$this->assertNull($this->getFormat()->getAudioChannels());
2014-06-25 09:55:00 +02:00
}
public function testSetAudioChannels()
{
$format = $this->getFormat();
$format->setAudioChannels(2);
$this->assertEquals(2, $format->getAudioChannels());
}
public function testSetInvalidChannels()
{
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
2014-06-25 09:55:00 +02:00
$this->getFormat()->setAudioChannels(0);
}
public function testSetNegativeChannels()
{
$this->expectException('\FFMpeg\Exception\InvalidArgumentException');
2014-06-25 09:55:00 +02:00
$this->getFormat()->setAudioChannels(-10);
}
2013-06-25 10:03:20 +02:00
public function testCreateProgressListener()
{
$media = $this->getMockBuilder('FFMpeg\Media\MediaTypeInterface')->getMock();
2013-06-25 10:03:20 +02:00
$media->expects($this->any())
->method('getPathfile')
->will($this->returnValue(__FILE__));
$format = $this->getFormat();
$ffprobe = $this->getFFProbeMock();
foreach ($format->createProgressListener($media, $ffprobe, 1, 3) as $listener) {
$this->assertInstanceOf('FFMpeg\Format\ProgressListener\AudioProgressListener', $listener);
$this->assertSame($ffprobe, $listener->getFFProbe());
$this->assertSame(__FILE__, $listener->getPathfile());
$this->assertSame(1, $listener->getCurrentPass());
$this->assertSame(3, $listener->getTotalPass());
}
}
/**
* @return DefaultAudio
*/
abstract public function getFormat();
}