scratch – Blame information for rev

Subversion Repositories:
Rev:
Rev Author Line No. Line
115 office 1 <?php
2  
3 namespace Tests\FFMpeg\Unit\Media;
4  
5 use FFMpeg\Media\Gif;
6 use FFMpeg\Coordinate\Dimension;
7  
8 class GifTest extends AbstractMediaTestCase
9 {
10 public function testGetTimeCode()
11 {
12 $driver = $this->getFFMpegDriverMock();
13 $ffprobe = $this->getFFProbeMock();
14 $timecode = $this->getTimeCodeMock();
15 $dimension = $this->getDimensionMock();
16  
17 $gif = new Gif($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode, $dimension);
18 $this->assertSame($timecode, $gif->getTimeCode());
19 }
20  
21 public function testGetDimension()
22 {
23 $driver = $this->getFFMpegDriverMock();
24 $ffprobe = $this->getFFProbeMock();
25 $timecode = $this->getTimeCodeMock();
26 $dimension = $this->getDimensionMock();
27  
28 $gif = new Gif($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode, $dimension);
29 $this->assertSame($dimension, $gif->getDimension());
30 }
31  
32 public function testFiltersReturnFilters()
33 {
34 $driver = $this->getFFMpegDriverMock();
35 $ffprobe = $this->getFFProbeMock();
36 $timecode = $this->getTimeCodeMock();
37 $dimension = $this->getDimensionMock();
38  
39 $gif = new Gif($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode, $dimension);
40 $this->assertInstanceOf('FFMpeg\Filters\Gif\GifFilters', $gif->filters());
41 }
42  
43 public function testAddFiltersAddsAFilter()
44 {
45 $driver = $this->getFFMpegDriverMock();
46 $ffprobe = $this->getFFProbeMock();
47 $timecode = $this->getTimeCodeMock();
48 $dimension = $this->getDimensionMock();
49  
50 $filters = $this->getMockBuilder('FFMpeg\Filters\FiltersCollection')
51 ->disableOriginalConstructor()
52 ->getMock();
53  
54 $filter = $this->getMock('FFMpeg\Filters\Gif\GifFilterInterface');
55  
56 $filters->expects($this->once())
57 ->method('add')
58 ->with($filter);
59  
60 $gif = new Gif($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode, $dimension);
61 $gif->setFiltersCollection($filters);
62 $gif->addFilter($filter);
63 }
64  
65 /**
66 * @dataProvider provideSaveOptions
67 */
68 public function testSave($dimension, $duration, $commands)
69 {
70 $driver = $this->getFFMpegDriverMock();
71 $ffprobe = $this->getFFProbeMock();
72 $timecode = $this->getTimeCodeMock();
73  
74 $timecode->expects($this->once())
75 ->method('__toString')
76 ->will($this->returnValue('timecode'));
77  
78 $pathfile = '/target/destination';
79  
80 array_push($commands, $pathfile);
81  
82 $driver->expects($this->once())
83 ->method('command')
84 ->with($commands);
85  
86 $gif = new Gif($this->getVideoMock(__FILE__), $driver, $ffprobe, $timecode, $dimension, $duration);
87 $this->assertSame($gif, $gif->save($pathfile));
88 }
89  
90 public function provideSaveOptions()
91 {
92 return array(
93 array(
94 new Dimension(320, 240), 3,
95 array(
96 '-ss', 'timecode',
97 '-t', '3',
98 '-i', __FILE__,
99 '-vf',
100 'scale=320:-1', '-gifflags',
101 '+transdiff', '-y'
102 ),
103 ),
104 array(
105 new Dimension(320, 240), null,
106 array(
107 '-ss', 'timecode',
108 '-i', __FILE__,
109 '-vf',
110 'scale=320:-1', '-gifflags',
111 '+transdiff', '-y'
112 )
113 ),
114 );
115 }
116 }