From f9c6316badaf4eef6d5376d46b498afdf6334cd4 Mon Sep 17 00:00:00 2001 From: Patrik Karisch Date: Sun, 6 Mar 2016 23:38:04 +0100 Subject: [PATCH] Cleanup phpunit configs and PSR-4 autoloading and namespaces for tests --- composer.json | 7 ++++- phpunit-functional.xml.dist | 27 ------------------- phpunit.xml.dist | 9 ++++--- tests/{FFMpeg => }/Functional/FFProbeTest.php | 4 +-- .../Functional/FunctionalTestCase.php | 2 +- .../Functional/VideoTranscodeTest.php | 10 +++---- .../Functional/output/.placeholder | 0 .../Coordinate/AspectRatioTest.php | 4 +-- .../Coordinate/DimensionTest.php | 4 +-- .../Coordinate/FrameRateTest.php | 4 +-- .../Tests => Unit}/Coordinate/PointTest.php | 4 +-- .../Coordinate/TimeCodeTest.php | 4 +-- .../Driver/FFMpegDriverTest.php | 4 +-- .../Driver/FFProbeDriverTest.php | 4 +-- .../FFMpegServiceProviderTest.php | 2 +- tests/{FFMpeg/Tests => Unit}/FFMpegTest.php | 2 +- .../FFProbe/DataMapping/AbstractDataTest.php | 4 +-- .../DataMapping/StreamCollectionTest.php | 4 +-- .../FFProbe/DataMapping/StreamTest.php | 4 +-- .../Tests => Unit}/FFProbe/MapperTest.php | 8 +++--- .../FFProbe/OptionsTesterTest.php | 6 ++--- .../FFProbe/OutputParserTest.php | 12 ++++----- tests/{FFMpeg/Tests => Unit}/FFProbeTest.php | 2 +- .../Filters/Audio/AudioFiltersTest.php | 4 +-- .../Audio/AudioResamplableFilterTest.php | 4 +-- .../Filters/FiltersCollectionTest.php | 4 +-- .../Frame/DisplayRatioFixerFilterTest.php | 4 +-- .../Filters/Frame/FrameFiltersTest.php | 4 +-- .../Filters/Video/CropFilterTest.php | 4 +-- .../Filters/Video/CustomFilterTest.php | 4 +-- .../Filters/Video/FrameRateFilterTest.php | 4 +-- .../Filters/Video/ResizeFilterTest.php | 4 +-- .../Filters/Video/RotateFilterTest.php | 4 +-- .../Filters/Video/SynchronizeFilterTest.php | 4 +-- .../Filters/Video/VideoFiltersTest.php | 4 +-- .../Filters/Video/WatermarkFilterTest.php | 24 ++++++++--------- .../Tests => Unit}/Format/Audio/AacTest.php | 2 +- .../Format/Audio/AudioTestCase.php | 4 +-- .../Tests => Unit}/Format/Audio/FlacTest.php | 2 +- .../Tests => Unit}/Format/Audio/Mp3Test.php | 2 +- .../Format/Audio/VorbisTest.php | 2 +- .../Tests => Unit}/Format/Audio/WavTest.php | 2 +- .../AudioProgressListenerTest.php | 4 +-- .../VideoProgressListenerTest.php | 4 +-- .../Tests => Unit}/Format/Video/OggTest.php | 2 +- .../Format/Video/VideoTestCase.php | 4 +-- .../Tests => Unit}/Format/Video/WMV3Test.php | 2 +- .../Tests => Unit}/Format/Video/WMVTest.php | 2 +- .../Tests => Unit}/Format/Video/WebMTest.php | 2 +- .../Tests => Unit}/Format/Video/X264Test.php | 2 +- .../Media/AbstractMediaTestCase.php | 4 +-- .../Media/AbstractStreamableTestCase.php | 2 +- .../Tests => Unit}/Media/AudioProg.php | 2 +- .../Tests => Unit}/Media/AudioTest.php | 4 +-- .../Tests => Unit}/Media/FrameTest.php | 2 +- tests/{FFMpeg/Tests => Unit}/Media/Prog.php | 2 +- .../Tests => Unit}/Media/VideoTest.php | 6 ++--- tests/{FFMpeg/Tests => Unit}/TestCase.php | 2 +- tests/bootstrap.php | 9 ++++--- 59 files changed, 128 insertions(+), 144 deletions(-) delete mode 100644 phpunit-functional.xml.dist rename tests/{FFMpeg => }/Functional/FFProbeTest.php (90%) rename tests/{FFMpeg => }/Functional/FunctionalTestCase.php (87%) rename tests/{FFMpeg => }/Functional/VideoTranscodeTest.php (90%) rename tests/{FFMpeg => }/Functional/output/.placeholder (100%) rename tests/{FFMpeg/Tests => Unit}/Coordinate/AspectRatioTest.php (97%) rename tests/{FFMpeg/Tests => Unit}/Coordinate/DimensionTest.php (91%) rename tests/{FFMpeg/Tests => Unit}/Coordinate/FrameRateTest.php (88%) rename tests/{FFMpeg/Tests => Unit}/Coordinate/PointTest.php (77%) rename tests/{FFMpeg/Tests => Unit}/Coordinate/TimeCodeTest.php (95%) rename tests/{FFMpeg/Tests => Unit}/Driver/FFMpegDriverTest.php (95%) rename tests/{FFMpeg/Tests => Unit}/Driver/FFProbeDriverTest.php (95%) rename tests/{FFMpeg/Tests => Unit}/FFMpegServiceProviderTest.php (98%) rename tests/{FFMpeg/Tests => Unit}/FFMpegTest.php (99%) rename tests/{FFMpeg/Tests => Unit}/FFProbe/DataMapping/AbstractDataTest.php (94%) rename tests/{FFMpeg/Tests => Unit}/FFProbe/DataMapping/StreamCollectionTest.php (96%) rename tests/{FFMpeg/Tests => Unit}/FFProbe/DataMapping/StreamTest.php (98%) rename tests/{FFMpeg/Tests => Unit}/FFProbe/MapperTest.php (87%) rename tests/{FFMpeg/Tests => Unit}/FFProbe/OptionsTesterTest.php (95%) rename tests/{FFMpeg/Tests => Unit}/FFProbe/OutputParserTest.php (72%) rename tests/{FFMpeg/Tests => Unit}/FFProbeTest.php (99%) rename tests/{FFMpeg/Tests => Unit}/Filters/Audio/AudioFiltersTest.php (89%) rename tests/{FFMpeg/Tests => Unit}/Filters/Audio/AudioResamplableFilterTest.php (88%) rename tests/{FFMpeg/Tests => Unit}/Filters/FiltersCollectionTest.php (96%) rename tests/{FFMpeg/Tests => Unit}/Filters/Frame/DisplayRatioFixerFilterTest.php (92%) rename tests/{FFMpeg/Tests => Unit}/Filters/Frame/FrameFiltersTest.php (84%) rename tests/{FFMpeg/Tests => Unit}/Filters/Video/CropFilterTest.php (94%) rename tests/{FFMpeg/Tests => Unit}/Filters/Video/CustomFilterTest.php (87%) rename tests/{FFMpeg/Tests => Unit}/Filters/Video/FrameRateFilterTest.php (94%) rename tests/{FFMpeg/Tests => Unit}/Filters/Video/ResizeFilterTest.php (98%) rename tests/{FFMpeg/Tests => Unit}/Filters/Video/RotateFilterTest.php (96%) rename tests/{FFMpeg/Tests => Unit}/Filters/Video/SynchronizeFilterTest.php (84%) rename tests/{FFMpeg/Tests => Unit}/Filters/Video/VideoFiltersTest.php (96%) rename tests/{FFMpeg/Tests => Unit}/Filters/Video/WatermarkFilterTest.php (59%) rename tests/{FFMpeg/Tests => Unit}/Format/Audio/AacTest.php (77%) rename tests/{FFMpeg/Tests => Unit}/Format/Audio/AudioTestCase.php (97%) rename tests/{FFMpeg/Tests => Unit}/Format/Audio/FlacTest.php (78%) rename tests/{FFMpeg/Tests => Unit}/Format/Audio/Mp3Test.php (77%) rename tests/{FFMpeg/Tests => Unit}/Format/Audio/VorbisTest.php (78%) rename tests/{FFMpeg/Tests => Unit}/Format/Audio/WavTest.php (77%) rename tests/{FFMpeg/Tests => Unit}/Format/ProgressListener/AudioProgressListenerTest.php (97%) rename tests/{FFMpeg/Tests => Unit}/Format/ProgressListener/VideoProgressListenerTest.php (97%) rename tests/{FFMpeg/Tests => Unit}/Format/Video/OggTest.php (77%) rename tests/{FFMpeg/Tests => Unit}/Format/Video/VideoTestCase.php (96%) rename tests/{FFMpeg/Tests => Unit}/Format/Video/WMV3Test.php (78%) rename tests/{FFMpeg/Tests => Unit}/Format/Video/WMVTest.php (77%) rename tests/{FFMpeg/Tests => Unit}/Format/Video/WebMTest.php (78%) rename tests/{FFMpeg/Tests => Unit}/Format/Video/X264Test.php (78%) rename tests/{FFMpeg/Tests => Unit}/Media/AbstractMediaTestCase.php (50%) rename tests/{FFMpeg/Tests => Unit}/Media/AbstractStreamableTestCase.php (96%) rename tests/{FFMpeg/Tests => Unit}/Media/AudioProg.php (82%) rename tests/{FFMpeg/Tests => Unit}/Media/AudioTest.php (98%) rename tests/{FFMpeg/Tests => Unit}/Media/FrameTest.php (98%) rename tests/{FFMpeg/Tests => Unit}/Media/Prog.php (81%) rename tests/{FFMpeg/Tests => Unit}/Media/VideoTest.php (99%) rename tests/{FFMpeg/Tests => Unit}/TestCase.php (99%) diff --git a/composer.json b/composer.json index 8fa6a0e..658a8c7 100644 --- a/composer.json +++ b/composer.json @@ -34,13 +34,18 @@ "require-dev": { "sami/sami": "~1.0", "silex/silex": "~1.0", - "phpunit/phpunit": "~3.7" + "phpunit/phpunit": "^4.8" }, "autoload": { "psr-0": { "FFMpeg": "src" } }, + "autoload-dev": { + "psr-4": { + "Tests\\FFMpeg\\": "tests" + } + }, "extra": { "branch-alias": { "dev-master": "0.6-dev" diff --git a/phpunit-functional.xml.dist b/phpunit-functional.xml.dist deleted file mode 100644 index 3f0f738..0000000 --- a/phpunit-functional.xml.dist +++ /dev/null @@ -1,27 +0,0 @@ - - - - - tests/FFMpeg/Functional - - - - - vendor - tests - - - - - diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f36c568..3027d1f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -12,16 +12,19 @@ bootstrap="tests/bootstrap.php" > - - tests/FFMpeg/Tests + + tests/Unit + + + tests/Functional + vendor tests - diff --git a/tests/FFMpeg/Functional/FFProbeTest.php b/tests/Functional/FFProbeTest.php similarity index 90% rename from tests/FFMpeg/Functional/FFProbeTest.php rename to tests/Functional/FFProbeTest.php index 5f7bb03..10a98c0 100644 --- a/tests/FFMpeg/Functional/FFProbeTest.php +++ b/tests/Functional/FFProbeTest.php @@ -1,6 +1,6 @@ assertGreaterThan(0, count($ffprobe->streams(__DIR__ . '/../../files/Audio.mp3'))); + $this->assertGreaterThan(0, count($ffprobe->streams(__DIR__ . '/../files/Audio.mp3'))); } /** diff --git a/tests/FFMpeg/Functional/FunctionalTestCase.php b/tests/Functional/FunctionalTestCase.php similarity index 87% rename from tests/FFMpeg/Functional/FunctionalTestCase.php rename to tests/Functional/FunctionalTestCase.php index 25e6461..02556ea 100644 --- a/tests/FFMpeg/Functional/FunctionalTestCase.php +++ b/tests/Functional/FunctionalTestCase.php @@ -1,6 +1,6 @@ getFFMpeg(); - $video = $ffmpeg->open(__DIR__ . '/../../files/Test.ogv'); + $video = $ffmpeg->open(__DIR__ . '/../files/Test.ogv'); $this->assertInstanceOf('FFMpeg\Media\Video', $video); @@ -46,13 +46,13 @@ class VideoTranscodeTest extends FunctionalTestCase public function testTranscodeInvalidFile() { $ffmpeg = $this->getFFMpeg(); - $ffmpeg->open(__DIR__ . '/../../files/UnknownFileTest.ogv'); + $ffmpeg->open(__DIR__ . '/../files/UnknownFileTest.ogv'); } public function testSaveInvalidForgedVideo() { $ffmpeg = $this->getFFMpeg(); - $video = new Video(__DIR__ . '/../../files/UnknownFileTest.ogv', $ffmpeg->getFFMpegDriver(), $ffmpeg->getFFProbe()); + $video = new Video(__DIR__ . '/../files/UnknownFileTest.ogv', $ffmpeg->getFFMpegDriver(), $ffmpeg->getFFProbe()); $this->setExpectedException('FFMpeg\Exception\RuntimeException'); $video->save(new X264('libvo_aacenc'), __DIR__ . '/output/output-x264.mp4'); @@ -72,7 +72,7 @@ class VideoTranscodeTest extends FunctionalTestCase } $ffmpeg = $this->getFFMpeg(); - $video = $ffmpeg->open(__DIR__ . '/../../files/portrait.MOV'); + $video = $ffmpeg->open(__DIR__ . '/../files/portrait.MOV'); $video->filters() ->resize(new Dimension(320, 240), ResizeFilter::RESIZEMODE_INSET) diff --git a/tests/FFMpeg/Functional/output/.placeholder b/tests/Functional/output/.placeholder similarity index 100% rename from tests/FFMpeg/Functional/output/.placeholder rename to tests/Functional/output/.placeholder diff --git a/tests/FFMpeg/Tests/Coordinate/AspectRatioTest.php b/tests/Unit/Coordinate/AspectRatioTest.php similarity index 97% rename from tests/FFMpeg/Tests/Coordinate/AspectRatioTest.php rename to tests/Unit/Coordinate/AspectRatioTest.php index 49e703c..100b6b7 100644 --- a/tests/FFMpeg/Tests/Coordinate/AspectRatioTest.php +++ b/tests/Unit/Coordinate/AspectRatioTest.php @@ -1,9 +1,9 @@ getMock('FFMpeg\Format\VideoInterface'); - $filter = new WatermarkFilter(__DIR__ . '/../../../../files/watermark.png'); - $this->assertEquals(array('-vf', 'movie='.__DIR__ .'/../../../../files/watermark.png [watermark]; [in][watermark] overlay=0:0 [out]'), $filter->apply($video, $format)); + $filter = new WatermarkFilter(__DIR__ . '/../../../files/watermark.png'); + $this->assertEquals(array('-vf', 'movie='.__DIR__ .'/../../../files/watermark.png [watermark]; [in][watermark] overlay=0:0 [out]'), $filter->apply($video, $format)); // check size of video is unchanged $this->assertEquals(320, $stream->get('width')); @@ -33,31 +33,31 @@ class WatermarkFilterTest extends TestCase $format = $this->getMock('FFMpeg\Format\VideoInterface'); // test position absolute - $filter = new WatermarkFilter(__DIR__ . '/../../../../files/watermark.png', array( + $filter = new WatermarkFilter(__DIR__ . '/../../../files/watermark.png', array( 'position' => 'absolute', 'x' => 10, 'y' => 5 )); - $this->assertEquals(array('-vf', 'movie='.__DIR__ .'/../../../../files/watermark.png [watermark]; [in][watermark] overlay=10:5 [out]'), $filter->apply($video, $format)); + $this->assertEquals(array('-vf', 'movie='.__DIR__ .'/../../../files/watermark.png [watermark]; [in][watermark] overlay=10:5 [out]'), $filter->apply($video, $format)); // test position relative - $filter = new WatermarkFilter(__DIR__ . '/../../../../files/watermark.png', array( + $filter = new WatermarkFilter(__DIR__ . '/../../../files/watermark.png', array( 'position' => 'relative', 'bottom' => 10, 'left' => 5 )); - $this->assertEquals(array('-vf', 'movie='.__DIR__ .'/../../../../files/watermark.png [watermark]; [in][watermark] overlay=5:main_h - 10 - overlay_h [out]'), $filter->apply($video, $format)); + $this->assertEquals(array('-vf', 'movie='.__DIR__ .'/../../../files/watermark.png [watermark]; [in][watermark] overlay=5:main_h - 10 - overlay_h [out]'), $filter->apply($video, $format)); // test position relative - $filter = new WatermarkFilter(__DIR__ . '/../../../../files/watermark.png', array( + $filter = new WatermarkFilter(__DIR__ . '/../../../files/watermark.png', array( 'position' => 'relative', 'bottom' => 5, 'right' => 4 )); - $this->assertEquals(array('-vf', 'movie='.__DIR__ .'/../../../../files/watermark.png [watermark]; [in][watermark] overlay=main_w - 4 - overlay_w:main_h - 5 - overlay_h [out]'), $filter->apply($video, $format)); + $this->assertEquals(array('-vf', 'movie='.__DIR__ .'/../../../files/watermark.png [watermark]; [in][watermark] overlay=main_w - 4 - overlay_w:main_h - 5 - overlay_h [out]'), $filter->apply($video, $format)); // test position relative - $filter = new WatermarkFilter(__DIR__ . '/../../../../files/watermark.png', array( + $filter = new WatermarkFilter(__DIR__ . '/../../../files/watermark.png', array( 'position' => 'relative', 'left' => 5, 'top' => 11 )); - $this->assertEquals(array('-vf', 'movie='.__DIR__ .'/../../../../files/watermark.png [watermark]; [in][watermark] overlay=5:11 [out]'), $filter->apply($video, $format)); + $this->assertEquals(array('-vf', 'movie='.__DIR__ .'/../../../files/watermark.png [watermark]; [in][watermark] overlay=5:11 [out]'), $filter->apply($video, $format)); } } diff --git a/tests/FFMpeg/Tests/Format/Audio/AacTest.php b/tests/Unit/Format/Audio/AacTest.php similarity index 77% rename from tests/FFMpeg/Tests/Format/Audio/AacTest.php rename to tests/Unit/Format/Audio/AacTest.php index 5e98e77..7c316b5 100644 --- a/tests/FFMpeg/Tests/Format/Audio/AacTest.php +++ b/tests/Unit/Format/Audio/AacTest.php @@ -1,6 +1,6 @@ getMock('Alchemy\BinaryDriver\Listeners\ListenerInterface')); - $progressableFormat = $this->getMockBuilder('FFMpeg\Tests\Media\AudioProg') + $progressableFormat = $this->getMockBuilder('Tests\FFMpeg\Unit\Media\AudioProg') ->disableOriginalConstructor()->getMock(); $progressableFormat->expects($this->any()) ->method('getExtraParams') diff --git a/tests/FFMpeg/Tests/Media/FrameTest.php b/tests/Unit/Media/FrameTest.php similarity index 98% rename from tests/FFMpeg/Tests/Media/FrameTest.php rename to tests/Unit/Media/FrameTest.php index 8f9af04..43f70c3 100644 --- a/tests/FFMpeg/Tests/Media/FrameTest.php +++ b/tests/Unit/Media/FrameTest.php @@ -1,6 +1,6 @@ getMock('Alchemy\BinaryDriver\Listeners\ListenerInterface')); - $progressableFormat = $this->getMockBuilder('FFMpeg\Tests\Media\Prog') + $progressableFormat = $this->getMockBuilder('Tests\FFMpeg\Unit\Media\Prog') ->disableOriginalConstructor()->getMock(); $progressableFormat->expects($this->any()) ->method('getExtraParams') @@ -353,7 +353,7 @@ class VideoTest extends AbstractStreamableTestCase ->method('getPasses') ->will($this->returnValue(2)); - $progressableAudioFormat = $this->getMockBuilder('FFMpeg\Tests\Media\AudioProg') + $progressableAudioFormat = $this->getMockBuilder('Tests\FFMpeg\Unit\Media\AudioProg') ->disableOriginalConstructor()->getMock(); $progressableAudioFormat->expects($this->any()) ->method('getExtraParams') diff --git a/tests/FFMpeg/Tests/TestCase.php b/tests/Unit/TestCase.php similarity index 99% rename from tests/FFMpeg/Tests/TestCase.php rename to tests/Unit/TestCase.php index 4757f95..5481599 100644 --- a/tests/FFMpeg/Tests/TestCase.php +++ b/tests/Unit/TestCase.php @@ -1,6 +1,6 @@ add('FFMpeg\Tests', __DIR__); -$loader->add('FFMpeg\Functional', __DIR__); +$file = __DIR__ . '/../vendor/autoload.php'; +if (!file_exists($file)) { + throw new RuntimeException('Install dependencies to run test suite.'); +} + +$autoload = require_once $file;