scratch – Blame information for rev 120
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
120 | office | 1 | <?php |
2 | |||
3 | namespace Tests\FFMpeg\Unit\Format\Audio; |
||
4 | |||
5 | use Tests\FFMpeg\Unit\TestCase; |
||
6 | use FFMpeg\Format\Audio\DefaultAudio; |
||
7 | |||
8 | abstract class AudioTestCase extends TestCase |
||
9 | { |
||
10 | public function testExtraParams() |
||
11 | { |
||
12 | foreach ($this->getFormat()->getExtraParams() as $param) { |
||
13 | $this->assertScalar($param); |
||
14 | } |
||
15 | } |
||
16 | |||
17 | public function testGetAudioCodec() |
||
18 | { |
||
19 | $this->assertScalar($this->getFormat()->getAudioCodec()); |
||
20 | $this->assertContains($this->getFormat()->getAudioCodec(), $this->getFormat()->getAvailableAudioCodecs()); |
||
21 | } |
||
22 | |||
23 | public function testSetAudioCodec() |
||
24 | { |
||
25 | $format = $this->getFormat(); |
||
26 | |||
27 | foreach ($format->getAvailableAudioCodecs() as $codec) { |
||
28 | $format->setAudioCodec($codec); |
||
29 | $this->assertEquals($codec, $format->getAudioCodec()); |
||
30 | } |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * @expectedException FFMpeg\Exception\InvalidArgumentException |
||
35 | */ |
||
36 | public function testSetInvalidAudioCodec() |
||
37 | { |
||
38 | $this->getFormat()->setAudioCodec('invalid-random-audio-codec'); |
||
39 | } |
||
40 | |||
41 | public function testGetAvailableAudioCodecs() |
||
42 | { |
||
43 | $this->assertGreaterThan(0, count($this->getFormat()->getAvailableAudioCodecs())); |
||
44 | } |
||
45 | |||
46 | public function testGetAudioKiloBitrate() |
||
47 | { |
||
48 | $this->assertInternalType('integer', $this->getFormat()->getAudioKiloBitrate()); |
||
49 | } |
||
50 | |||
51 | public function testSetAudioKiloBitrate() |
||
52 | { |
||
53 | $format = $this->getFormat(); |
||
54 | $format->setAudioKiloBitrate(256); |
||
55 | $this->assertEquals(256, $format->getAudioKiloBitrate()); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @expectedException FFMpeg\Exception\InvalidArgumentException |
||
60 | */ |
||
61 | public function testSetInvalidKiloBitrate() |
||
62 | { |
||
63 | $this->getFormat()->setAudioKiloBitrate(0); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @expectedException FFMpeg\Exception\InvalidArgumentException |
||
68 | */ |
||
69 | public function testSetNegativeKiloBitrate() |
||
70 | { |
||
71 | $this->getFormat()->setAudioKiloBitrate(-10); |
||
72 | } |
||
73 | |||
74 | public function testGetAudioChannels() |
||
75 | { |
||
76 | $this->assertInternalType('null', $this->getFormat()->getAudioChannels()); |
||
77 | } |
||
78 | |||
79 | public function testSetAudioChannels() |
||
80 | { |
||
81 | $format = $this->getFormat(); |
||
82 | $format->setAudioChannels(2); |
||
83 | $this->assertEquals(2, $format->getAudioChannels()); |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * @expectedException FFMpeg\Exception\InvalidArgumentException |
||
88 | */ |
||
89 | public function testSetInvalidChannels() |
||
90 | { |
||
91 | $this->getFormat()->setAudioChannels(0); |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * @expectedException FFMpeg\Exception\InvalidArgumentException |
||
96 | */ |
||
97 | public function testSetNegativeChannels() |
||
98 | { |
||
99 | $this->getFormat()->setAudioChannels(-10); |
||
100 | } |
||
101 | |||
102 | public function testCreateProgressListener() |
||
103 | { |
||
104 | $media = $this->getMock('FFMpeg\Media\MediaTypeInterface'); |
||
105 | $media->expects($this->any()) |
||
106 | ->method('getPathfile') |
||
107 | ->will($this->returnValue(__FILE__)); |
||
108 | $format = $this->getFormat(); |
||
109 | $ffprobe = $this->getFFProbeMock(); |
||
110 | |||
111 | foreach ($format->createProgressListener($media, $ffprobe, 1, 3) as $listener) { |
||
112 | $this->assertInstanceOf('FFMpeg\Format\ProgressListener\AudioProgressListener', $listener); |
||
113 | $this->assertSame($ffprobe, $listener->getFFProbe()); |
||
114 | $this->assertSame(__FILE__, $listener->getPathfile()); |
||
115 | $this->assertSame(1, $listener->getCurrentPass()); |
||
116 | $this->assertSame(3, $listener->getTotalPass()); |
||
117 | } |
||
118 | } |
||
119 | |||
120 | /** |
||
121 | * @return DefaultAudio |
||
122 | */ |
||
123 | abstract public function getFormat(); |
||
124 | } |