scratch – Blame information for rev 115
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
115 | office | 1 | <?php |
2 | |||
3 | namespace Tests\FFMpeg\Unit\Filters\Video; |
||
4 | |||
5 | use FFMpeg\FFProbe\DataMapping\Stream; |
||
6 | use FFMpeg\FFProbe\DataMapping\StreamCollection; |
||
7 | use FFMpeg\Filters\Video\RotateFilter; |
||
8 | use Tests\FFMpeg\Unit\TestCase; |
||
9 | |||
10 | class RotateFilterTest extends TestCase |
||
11 | { |
||
12 | /** |
||
13 | * @dataProvider provide90degresTranspositions |
||
14 | */ |
||
15 | public function testApplyWithSizeTransformation($value) |
||
16 | { |
||
17 | $stream = new Stream(array('width' => 320, 'height' => 240, 'codec_type' => 'video')); |
||
18 | $streams = new StreamCollection(array($stream)); |
||
19 | |||
20 | $video = $this->getVideoMock(); |
||
21 | $video->expects($this->once()) |
||
22 | ->method('getStreams') |
||
23 | ->will($this->returnValue($streams)); |
||
24 | |||
25 | $format = $this->getMock('FFMpeg\Format\VideoInterface'); |
||
26 | |||
27 | $filter = new RotateFilter($value); |
||
28 | $this->assertEquals(array('-vf', $value, '-metadata:s:v:0', 'rotate=0'), $filter->apply($video, $format)); |
||
29 | |||
30 | $this->assertEquals(240, $stream->get('width')); |
||
31 | $this->assertEquals(320, $stream->get('height')); |
||
32 | } |
||
33 | |||
34 | public function provide90degresTranspositions() |
||
35 | { |
||
36 | return array( |
||
37 | array(RotateFilter::ROTATE_90), |
||
38 | array(RotateFilter::ROTATE_270), |
||
39 | ); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @dataProvider provideDegresWithoutTranspositions |
||
44 | */ |
||
45 | public function testApplyWithoutSizeTransformation($value) |
||
46 | { |
||
47 | $video = $this->getVideoMock(); |
||
48 | $video->expects($this->never()) |
||
49 | ->method('getStreams'); |
||
50 | |||
51 | $format = $this->getMock('FFMpeg\Format\VideoInterface'); |
||
52 | |||
53 | $filter = new RotateFilter($value); |
||
54 | $this->assertEquals(array('-vf', $value, '-metadata:s:v:0', 'rotate=0'), $filter->apply($video, $format)); |
||
55 | } |
||
56 | |||
57 | public function provideDegresWithoutTranspositions() |
||
58 | { |
||
59 | return array( |
||
60 | array(RotateFilter::ROTATE_180), |
||
61 | ); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @expectedException \FFMpeg\Exception\InvalidArgumentException |
||
66 | * @expectedExceptionMessage Invalid angle value. |
||
67 | */ |
||
68 | public function testApplyInvalidAngle() |
||
69 | { |
||
70 | new RotateFilter('90'); |
||
71 | } |
||
72 | } |