Skip to content

Commit bbe9478

Browse files
author
Romain Biard
committed
Addition of the tests
1 parent 7c4eed6 commit bbe9478

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

Diff for: composer.json

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
"name": "Patrik Karisch",
2020
"email": "[email protected]",
2121
"homepage": "http://www.karisch.guru"
22+
},
23+
{
24+
"name": "Romain Biard",
25+
"email": "[email protected]",
26+
"homepage": "https://www.strime.io/"
2227
}
2328
],
2429
"require": {

Diff for: tests/Unit/Filters/Video/PadFilterTest.php

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace Tests\FFMpeg\Unit\Filters\Video;
4+
5+
use FFMpeg\Filters\Video\PadFilter;
6+
use Tests\FFMpeg\Unit\TestCase;
7+
use FFMpeg\FFProbe\DataMapping\Stream;
8+
use FFMpeg\FFProbe\DataMapping\StreamCollection;
9+
use FFMpeg\Coordinate\Dimension;
10+
11+
class PadFilterTest extends TestCase
12+
{
13+
/**
14+
* @dataProvider provideDimensions
15+
*/
16+
public function testApply(Dimension $dimension, $width, $height, $expected)
17+
{
18+
$video = $this->getVideoMock();
19+
$pathfile = '/path/to/file'.mt_rand();
20+
21+
$format = $this->createMock('FFMpeg\Format\VideoInterface');
22+
23+
$streams = new StreamCollection(array(
24+
new Stream(array(
25+
'codec_type' => 'video',
26+
'width' => $width,
27+
'height' => $height,
28+
))
29+
));
30+
31+
$filter = new PadFilter($dimension);
32+
$this->assertEquals($expected, $filter->apply($video, $format));
33+
}
34+
35+
public function provideDimensions()
36+
{
37+
return array(
38+
array(new Dimension(1000, 800), 640, 480, array('-vf', 'scale=iw*min(1000/iw\,800/ih):ih*min(1000/iw\,800/ih),pad=1000:800:(1000-iw)/2:(800-ih)/2')),
39+
array(new Dimension(300, 600), 640, 480, array('-vf', 'scale=iw*min(300/iw\,600/ih):ih*min(300/iw\,600/ih),pad=300:600:(300-iw)/2:(600-ih)/2')),
40+
array(new Dimension(100, 900), 640, 480, array('-vf', 'scale=iw*min(100/iw\,900/ih):ih*min(100/iw\,900/ih),pad=100:900:(100-iw)/2:(900-ih)/2')),
41+
array(new Dimension(1200, 200), 640, 480, array('-vf', 'scale=iw*min(1200/iw\,200/ih):ih*min(1200/iw\,200/ih),pad=1200:200:(1200-iw)/2:(200-ih)/2')),
42+
);
43+
}
44+
}

0 commit comments

Comments
 (0)