scratch – Blame information for rev 122
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
120 | office | 1 | <?php |
2 | |||
3 | namespace Tests\FFMpeg\Unit\FFProbe\DataMapping; |
||
4 | |||
5 | use Tests\FFMpeg\Unit\TestCase; |
||
6 | use FFMpeg\FFProbe\DataMapping\StreamCollection; |
||
7 | |||
8 | class StreamCollectionTest extends TestCase |
||
9 | { |
||
10 | public function testAdd() |
||
11 | { |
||
12 | $stream = $this->getStreamMock(); |
||
13 | |||
14 | $collection = new StreamCollection(); |
||
15 | $this->assertEquals(array(), $collection->all()); |
||
16 | $collection->add($stream); |
||
17 | $this->assertEquals(array($stream), $collection->all()); |
||
18 | $collection->add($stream); |
||
19 | $this->assertEquals(array($stream, $stream), $collection->all()); |
||
20 | } |
||
21 | |||
22 | public function testVideos() |
||
23 | { |
||
24 | $audio = $this->getStreamMock(); |
||
25 | $audio->expects($this->once()) |
||
26 | ->method('isVideo') |
||
27 | ->will($this->returnValue(false)); |
||
28 | |||
29 | $video = $this->getStreamMock(); |
||
30 | $video->expects($this->once()) |
||
31 | ->method('isVideo') |
||
32 | ->will($this->returnValue(true)); |
||
33 | |||
34 | $collection = new StreamCollection(array($audio, $video)); |
||
35 | $videos = $collection->videos(); |
||
36 | |||
37 | $this->assertInstanceOf('FFMpeg\FFProbe\DataMapping\StreamCollection', $videos); |
||
38 | $this->assertCount(1, $videos); |
||
39 | $this->assertEquals(array($video), $videos->all()); |
||
40 | } |
||
41 | |||
42 | public function testAudios() |
||
43 | { |
||
44 | $audio = $this->getStreamMock(); |
||
45 | $audio->expects($this->once()) |
||
46 | ->method('isAudio') |
||
47 | ->will($this->returnValue(true)); |
||
48 | |||
49 | $video = $this->getStreamMock(); |
||
50 | $video->expects($this->once()) |
||
51 | ->method('isAudio') |
||
52 | ->will($this->returnValue(false)); |
||
53 | |||
54 | $collection = new StreamCollection(array($audio, $video)); |
||
55 | $audios = $collection->audios(); |
||
56 | |||
57 | $this->assertInstanceOf('FFMpeg\FFProbe\DataMapping\StreamCollection', $audios); |
||
58 | $this->assertCount(1, $audios); |
||
59 | $this->assertEquals(array($audio), $audios->all()); |
||
60 | } |
||
61 | |||
62 | public function testCount() |
||
63 | { |
||
64 | $stream = $this->getStreamMock(); |
||
65 | |||
66 | $collection = new StreamCollection(array($stream)); |
||
67 | $this->assertCount(1, $collection); |
||
68 | } |
||
69 | |||
70 | public function testGetIterator() |
||
71 | { |
||
72 | $audio = $this->getStreamMock(); |
||
73 | $video = $this->getStreamMock(); |
||
74 | |||
75 | $collection = new StreamCollection(array($audio, $video)); |
||
76 | $this->assertInstanceOf('\Iterator', $collection->getIterator()); |
||
77 | $this->assertCount(2, $collection->getIterator()); |
||
78 | } |
||
79 | |||
80 | public function testFirst() |
||
81 | { |
||
82 | $stream1 = $this->getStreamMock(); |
||
83 | $stream2 = $this->getStreamMock(); |
||
84 | |||
85 | $coll = new StreamCollection(array($stream1, $stream2)); |
||
86 | |||
87 | $this->assertSame($stream1, $coll->first()); |
||
88 | } |
||
89 | } |