Skip to content

Commit

Permalink
Exclude tests from dist and code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
javer committed Sep 2, 2020
1 parent 3f36052 commit dcf90bd
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 27 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/tests export-ignore
/.* export-ignore
/phpcs.xml.dist export-ignore
/phpunit.xml.dist export-ignore
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/composer.lock
/composer.phar
/phpunit.xml
/.phpunit.result.cache
/vendor/
/.phpcs-cache
/phpcs.xml
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ php:
- 7.1
- 7.2
- 7.3
- 7.4snapshot
- 7.4

before_script: composer install -n --dev

script:
- vendor/bin/phpcs
- vendor/bin/phpunit --coverage-text

allow_failures:
- php: 7.4snapshot
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "library",
"description": "FFmpeg transformation command builder",
"keywords": ["ffmpeg", "transformer", "adapter", "command", "builder"],
"homepage": "https://github.com/javer",
"homepage": "https://github.com/javer/ffmpeg-transformer",
"license": "MIT",
"authors": [
{
Expand All @@ -17,7 +17,7 @@
"php-ffmpeg/php-ffmpeg": ">=0.7"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"squizlabs/php_codesniffer": "3.5.*",
"swivl/php-coding-standard": "^1.0"
},
Expand Down
5 changes: 1 addition & 4 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,5 @@
<file>src/</file>
<file>tests/</file>

<rule ref="vendor/swivl/php-coding-standard/Swivl/ruleset.xml">
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.FirstExpressionLine"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.CloseParenthesisLine"/>
</rule>
<rule ref="vendor/swivl/php-coding-standard/Swivl/ruleset.xml" />
</ruleset>
12 changes: 8 additions & 4 deletions src/Transformer/ProfileTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,17 @@ public function transformVideo(VideoProfile $source, VideoProfile $target, bool

$targetFramerate = $this->getLeastValue($sourceFrameRate, $target->getFrameRate());

if ($force
if (
$force
|| $sourceCodec !== $targetCodec
|| $sourcePixelFormat !== $targetPixelFormat
|| $sourceRotate != 0
|| $sourceWidth > $targetWidth
|| $sourceHeight > $targetHeight
|| $sourceBitrate > $targetBitrate
|| $sourceBitrate > $targetMaxrate
|| $sourceFrameRate > $targetFramerate) {
|| $sourceFrameRate > $targetFramerate
) {
$transform->setCodec($targetCodec);
$transform->setProfile($target->getProfile());
$transform->setPreset($this->getVideoCodecPreset($targetCodec, $target->getPreset(), $targetFramerate));
Expand Down Expand Up @@ -166,11 +168,13 @@ public function transformAudio(AudioProfile $source, AudioProfile $target, bool

$targetChannels = $this->getLeastValue($source->getChannels(), $target->getChannels());

if ($force
if (
$force
|| $source->getCodec() !== $targetCodec
|| $source->getBitrate() > $targetBitrate
|| $source->getSampleRate() > $targetSampleRate
|| $source->getChannels() > $targetChannels) {
|| $source->getChannels() > $targetChannels
) {
$transform->setCodec($targetCodec);
$transform->setProfile($target->getProfile());
$transform->setBitrate($targetBitrate);
Expand Down
24 changes: 12 additions & 12 deletions tests/Command/CommandTest.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace Javer\FfmpegTransformer\Tests\Ffmpeg\Command;
namespace Javer\FfmpegTransformer\Tests\Command;

use Javer\FfmpegTransformer\Command\Command;
use PHPUnit\Framework\TestCase;

/**
* Class CommandTest
*
* @package Javer\FfmpegTransformer\Tests\Ffmpeg\Command
* @package Javer\FfmpegTransformer\Tests\Command
*/
class CommandTest extends TestCase
{
Expand All @@ -27,7 +27,7 @@ public function testFormatChange(): void
->addVideoStream($inputFile->getVideoStream())->end()
->addAudioStream($inputFile->getAudioStream())->end();

$this->assertEquals([
self::assertEquals([
'-y',
'-i', 'input.mov',
'-movflags', 'faststart',
Expand Down Expand Up @@ -58,7 +58,7 @@ public function testTranscodingSingleVideoAndAudio(): void
->codec('aac')
->end();

$this->assertEquals([
self::assertEquals([
'-y',
'-i', 'input.mov',
'-movflags', 'faststart',
Expand Down Expand Up @@ -87,7 +87,7 @@ public function testAudioSplitting(): void
->bitrate('64k')
->end();

$this->assertEquals([
self::assertEquals([
'-y',
'-i', 'input.mov',
'-movflags', 'faststart',
Expand All @@ -114,7 +114,7 @@ public function testVideoTrim(): void
->addVideoStream($inputFile->getVideoStream())->end()
->addAudioStream($inputFile->getAudioStream())->end();

$this->assertEquals([
self::assertEquals([
'-y',
'-i', 'input.mov',
'-movflags', 'faststart',
Expand Down Expand Up @@ -153,7 +153,7 @@ public function testExtractAudioTracks(): void
->codec('libx264')
->preset('ultrafast');

$this->assertEquals([
self::assertEquals([
'-y',
'-i', 'input.mov',
'-f', 'rawvideo', '-s:v:0', '16x16', '-pix_fmt:v:0', 'rgb24', '-r:v:0', '1', '-i', '/dev/zero',
Expand Down Expand Up @@ -204,7 +204,7 @@ public function testFilterGraphVideoAudio(): void
$outputFile->addAudioStream($outputAudioStream)
->codec('aac');

$this->assertEquals([
self::assertEquals([
'-y',
'-i', 'input.mp4',
'-movflags', 'faststart',
Expand Down Expand Up @@ -257,7 +257,7 @@ public function testFilterGraphPadLeftRight(): void
$outputFile->addAudioStream($outputAudioStream)
->codec('aac');

$this->assertEquals([
self::assertEquals([
'-y',
'-i', 'input.mp4',
'-f', 'rawvideo', '-t', '10', '-s:v:0','640x480', '-pix_fmt:v:0', 'rgb24', '-i', '/dev/zero',
Expand Down Expand Up @@ -339,7 +339,7 @@ public function testFilterGraphSyncRanges(): void
$outputFile->addAudioStream($outputAudioStream)
->codec('aac');

$this->assertEquals([
self::assertEquals([
'-y',
'-i', 'input.mp4',
'-f', 'rawvideo', '-t', '5', '-s:v:0', '640x480', '-pix_fmt:v:0', 'rgb24', '-i', '/dev/zero',
Expand Down Expand Up @@ -438,7 +438,7 @@ public function testMixAndNormalizeAudioTracks(): void
$outputMixedAudioStream->map($mixedAudioStream);
$outputMixedAudioStream->codec($codec);

$this->assertEquals([
self::assertEquals([
'-y',
'-i', 'input.mp4',
'-movflags', 'faststart',
Expand Down Expand Up @@ -529,7 +529,7 @@ public function testMoveStreamToPosition(): void
$outputMixedAudioStream->moveTo(0);
$outputMixedAudioStream->codec($codec);

$this->assertEquals([
self::assertEquals([
'-y',
'-i', 'input.mp4',
'-movflags', 'faststart',
Expand Down
2 changes: 1 addition & 1 deletion tests/Profile/MediaProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ public function testFromAndToArray(): void
],
];

$this->assertEquals($serializedProfile, $mediaProfile->toArray());
self::assertEquals($serializedProfile, $mediaProfile->toArray());
}
}

0 comments on commit dcf90bd

Please sign in to comment.