Migrate everything to latest versions

Use newest symfony version, newest PHP and newest PHPUnit.
Remove prophecy dependency.
This commit is contained in:
Daniel Siepmann 2023-02-07 08:03:10 +01:00
parent 5838745b96
commit 808da86d12
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
6 changed files with 678 additions and 1058 deletions

View file

@ -30,7 +30,7 @@ Installation
Install requirements:
* PHP 7.3 command line
* PHP 8.2 command line
* ffmpeg

View file

@ -15,13 +15,11 @@
}
},
"require": {
"php": "7.3.*",
"symfony/console": "^5.1",
"symfony/process": "^5.1"
"php": "8.2.*",
"symfony/console": "^6.2",
"symfony/process": "^6.2"
},
"require-dev": {
"phpunit/phpunit": "^9.3",
"phpspec/prophecy": "^1.12",
"phpspec/prophecy-phpunit": "^2.0"
"phpunit/phpunit": "^10.0"
}
}

1543
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,27 +1,23 @@
<?xml version="1.0"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
>
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
requireCoverageMetadata="false"
>
<testsuites>
<testsuite name="unit">
<directory>tests/Unit/</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">src</directory>

View file

@ -24,7 +24,6 @@ namespace DanielSiepmann\Videcutting\Tests\Unit;
use DanielSiepmann\Videcutting\Cutting;
use DanielSiepmann\Videcutting\VideoInfo;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\Process\Process;
/**
@ -32,16 +31,14 @@ use Symfony\Component\Process\Process;
*/
class CuttingTest extends TestCase
{
use ProphecyTrait;
/**
* @test
*/
public function instanceCanBeCreated(): void
{
$video = $this->prophesize(VideoInfo::class);
$video = $this->createStub(VideoInfo::class);
$subject = new Cutting(
$video->reveal()
$video
);
static::assertInstanceOf(Cutting::class, $subject);
@ -52,15 +49,15 @@ class CuttingTest extends TestCase
*/
public function generatesCommandsForCuttingWithoutAds(): void
{
$video = $this->prophesize(VideoInfo::class);
$video->getStart()->willReturn('10.05.20');
$video->getEnd()->willReturn('13.10.25');
$video->getAds()->willReturn([]);
$video->getOriginalFilename()->willReturn('Some-Video.mp4');
$video->getOriginalFilenameWithSuffix('cut-1')->willReturn('Some-Video-cut-1.mp4');
$video = $this->createStub(VideoInfo::class);
$video->method('getStart')->willReturn('10.05.20');
$video->method('getEnd')->willReturn('13.10.25');
$video->method('getAds')->willReturn([]);
$video->method('getOriginalFilename')->willReturn('Some-Video.mp4');
$video->method('getOriginalFilenameWithSuffix')->willReturn('Some-Video-cut-1.mp4');
$subject = new Cutting(
$video->reveal()
$video
);
$commands = [];
@ -70,7 +67,7 @@ class CuttingTest extends TestCase
static::assertCount(1, $commands);
static::assertSame(
"ffmpeg -y -ss '10.05.20' -to '13.10.25' -i 'Some-Video.mp4' -c copy '/tmp/Some-Video-cut-1.mp4'",
"ffmpeg -y -ss '10.05.20' -to '13.10.25' -i 'Some-Video.mp4' -c copy '" . sys_get_temp_dir() . "/Some-Video-cut-1.mp4'",
$commands[0]->getCommandLine()
);
}
@ -80,20 +77,22 @@ class CuttingTest extends TestCase
*/
public function generatesCommandsForCuttingWithAds(): void
{
$video = $this->prophesize(VideoInfo::class);
$video->getStart()->willReturn('1:05.20');
$video->getEnd()->willReturn('13:10.25');
$video->getAds()->willReturn([
$video = $this->createStub(VideoInfo::class);
$video->method('getStart')->willReturn('1:05.20');
$video->method('getEnd')->willReturn('13:10.25');
$video->method('getAds')->willReturn([
['2:10', '3:05'],
['10:07', '11:10'],
]);
$video->getOriginalFilename()->willReturn('Some-Video.mp4');
$video->getOriginalFilenameWithSuffix('cut-1')->willReturn('Some-Video-cut-1.mp4');
$video->getOriginalFilenameWithSuffix('cut-2')->willReturn('Some-Video-cut-2.mp4');
$video->getOriginalFilenameWithSuffix('cut-3')->willReturn('Some-Video-cut-3.mp4');
$video->method('getOriginalFilename')->willReturn('Some-Video.mp4');
$video->method('getOriginalFilenameWithSuffix')->willReturnOnConsecutiveCalls(
'Some-Video-cut-1.mp4',
'Some-Video-cut-2.mp4',
'Some-Video-cut-3.mp4',
);
$subject = new Cutting(
$video->reveal()
$video
);
$commands = [];
@ -103,15 +102,15 @@ class CuttingTest extends TestCase
static::assertCount(3, $commands, 'Did not get expected number of cutting commands');
static::assertSame(
"ffmpeg -y -ss '1:05.20' -to '2:10' -i 'Some-Video.mp4' -c copy '/tmp/Some-Video-cut-1.mp4'",
"ffmpeg -y -ss '1:05.20' -to '2:10' -i 'Some-Video.mp4' -c copy '" . sys_get_temp_dir() . "/Some-Video-cut-1.mp4'",
$commands[0]->getCommandLine()
);
static::assertSame(
"ffmpeg -y -ss '3:05' -to '10:07' -i 'Some-Video.mp4' -c copy '/tmp/Some-Video-cut-2.mp4'",
"ffmpeg -y -ss '3:05' -to '10:07' -i 'Some-Video.mp4' -c copy '" . sys_get_temp_dir() . "/Some-Video-cut-2.mp4'",
$commands[1]->getCommandLine()
);
static::assertSame(
"ffmpeg -y -ss '11:10' -to '13:10.25' -i 'Some-Video.mp4' -c copy '/tmp/Some-Video-cut-3.mp4'",
"ffmpeg -y -ss '11:10' -to '13:10.25' -i 'Some-Video.mp4' -c copy '" . sys_get_temp_dir() . "/Some-Video-cut-3.mp4'",
$commands[2]->getCommandLine()
);
}
@ -121,18 +120,18 @@ class CuttingTest extends TestCase
*/
public function generatesCommandForGeneratingMetadata(): void
{
$video = $this->prophesize(VideoInfo::class);
$video->getOriginalFilename()->willReturn('Some-Video.mp4');
$video->getOriginalFilenameWithSuffix('metadata')->willReturn('Some-Video-metadata.mp4');
$video = $this->createStub(VideoInfo::class);
$video->method('getOriginalFilename')->willReturn('Some-Video.mp4');
$video->method('getOriginalFilenameWithSuffix')->willReturn('Some-Video-metadata.mp4');
$subject = new Cutting(
$video->reveal()
$video
);
$command = $subject->getCommandForGeneratingMetadata();
static::assertSame(
"ffmpeg -y -i 'Some-Video.mp4' -f ffmetadata '/tmp/Some-Video-metadata.txt'",
"ffmpeg -y -i 'Some-Video.mp4' -f ffmetadata '" . sys_get_temp_dir() . "/Some-Video-metadata.txt'",
$command->getCommandLine()
);
}
@ -142,10 +141,10 @@ class CuttingTest extends TestCase
*/
public function throwsExceptionForGeneratingConcatInputFileIfNoConcatIsAvailable(): void
{
$video = $this->prophesize(VideoInfo::class);
$video = $this->createStub(VideoInfo::class);
$subject = new Cutting(
$video->reveal()
$video
);
$this->expectException(\InvalidArgumentException::class);
@ -160,16 +159,18 @@ class CuttingTest extends TestCase
*/
public function generatesCommandsForGeneratingConcatInputFileWithNoAds(): void
{
$video = $this->prophesize(VideoInfo::class);
$video->getStart()->willReturn('10.05.20');
$video->getEnd()->willReturn('13.10.25');
$video->getAds()->willReturn([]);
$video->getOriginalFilename()->willReturn('Some-Video.mp4');
$video->getOriginalFilenameWithSuffix('cut-1')->willReturn('Some-Video-cut-1.mp4');
$video->getOriginalFilenameWithSuffix('concat')->willReturn('Some-Video-concat.mp4');
$video = $this->createStub(VideoInfo::class);
$video->method('getStart')->willReturn('10.05.20');
$video->method('getEnd')->willReturn('13.10.25');
$video->method('getAds')->willReturn([]);
$video->method('getOriginalFilename')->willReturn('Some-Video.mp4');
$video->method('getOriginalFilenameWithSuffix')->willReturnOnConsecutiveCalls(
'Some-Video-cut-1.mp4',
'Some-Video-concat.mp4'
);
$subject = new Cutting(
$video->reveal()
$video
);
foreach ($subject->getCommandsForCutting() as $command) {
@ -179,7 +180,7 @@ class CuttingTest extends TestCase
$command = $subject->getCommandForGeneratingConcatInputFile();
static::assertSame(
"printf 'file /tmp/Some-Video-cut-1.mp4' > /tmp/Some-Video-concat.txt",
"printf 'file " . sys_get_temp_dir() . "/Some-Video-cut-1.mp4' > " . sys_get_temp_dir() . "/Some-Video-concat.txt",
$command->getCommandLine()
);
}
@ -189,21 +190,23 @@ class CuttingTest extends TestCase
*/
public function generatesCommandsForGeneratingConcatInputFileWithAds(): void
{
$video = $this->prophesize(VideoInfo::class);
$video->getStart()->willReturn('10.05.20');
$video->getEnd()->willReturn('13.10.25');
$video->getAds()->willReturn([
$video = $this->createStub(VideoInfo::class);
$video->method('getStart')->willReturn('10.05.20');
$video->method('getEnd')->willReturn('13.10.25');
$video->method('getAds')->willReturn([
['2:10', '3:05'],
['10:07', '11:10'],
]);
$video->getOriginalFilename()->willReturn('Some-Video.mp4');
$video->getOriginalFilenameWithSuffix('cut-1')->willReturn('Some-Video-cut-1.mp4');
$video->getOriginalFilenameWithSuffix('cut-2')->willReturn('Some-Video-cut-2.mp4');
$video->getOriginalFilenameWithSuffix('cut-3')->willReturn('Some-Video-cut-3.mp4');
$video->getOriginalFilenameWithSuffix('concat')->willReturn('Some-Video-concat.mp4');
$video->method('getOriginalFilename')->willReturn('Some-Video.mp4');
$video->method('getOriginalFilenameWithSuffix')->willReturnOnConsecutiveCalls(
'Some-Video-cut-1.mp4',
'Some-Video-cut-2.mp4',
'Some-Video-cut-3.mp4',
'Some-Video-concat.mp4'
);
$subject = new Cutting(
$video->reveal()
$video
);
foreach ($subject->getCommandsForCutting() as $command) {
@ -213,8 +216,8 @@ class CuttingTest extends TestCase
$command = $subject->getCommandForGeneratingConcatInputFile();
static::assertSame(
'printf \'file /tmp/Some-Video-cut-1.mp4\nfile /tmp/Some-Video-cut-2.mp4\nfile /tmp/Some-Video-cut-3.mp4\''
. ' > /tmp/Some-Video-concat.txt',
'printf \'file ' . sys_get_temp_dir() . '/Some-Video-cut-1.mp4\nfile ' . sys_get_temp_dir() . '/Some-Video-cut-2.mp4\nfile ' . sys_get_temp_dir() . '/Some-Video-cut-3.mp4\''
. ' > ' . sys_get_temp_dir() . '/Some-Video-concat.txt',
$command->getCommandLine()
);
}
@ -224,21 +227,23 @@ class CuttingTest extends TestCase
*/
public function generatesCommandForGeneratingVideoWithCustomTitle(): void
{
$video = $this->prophesize(VideoInfo::class);
$video->getTargetFilePath()->willReturn('Series-Name/Series-01/10-episode title.mp4');
$video->getOriginalFilenameWithSuffix('concat')->willReturn('Series-Name_Series-01_episode-title-01-concat.mp4');
$video->getOriginalFilenameWithSuffix('metadata')->willReturn('Series-Name_Series-01_episode-title-01-metadata.mp4');
$video->getTitleForHumans()->willReturn('01 - Episode Title');
$video = $this->createStub(VideoInfo::class);
$video->method('getTargetFilePath')->willReturn('Series-Name/Series-01/10-episode title.mp4');
$video->method('getOriginalFilenameWithSuffix')->willReturnOnConsecutiveCalls(
'Series-Name_Series-01_episode-title-01-concat.mp4',
'Series-Name_Series-01_episode-title-01-metadata.mp4'
);
$video->method('getTitleForHumans')->willReturn('01 - Episode Title');
$subject = new Cutting(
$video->reveal()
$video
);
$command = $subject->getCommandForGeneratingVideo();
static::assertSame(
'ffmpeg -y -f concat -safe 0 -i \'/tmp/Series-Name_Series-01_episode-title-01-concat.txt\' -c copy'
. ' -f ffmetadata -i \'/tmp/Series-Name_Series-01_episode-title-01-metadata.txt\' -c copy -map_metadata 1'
'ffmpeg -y -f concat -safe 0 -i \'' . sys_get_temp_dir() . '/Series-Name_Series-01_episode-title-01-concat.txt\' -c copy'
. ' -f ffmetadata -i \'' . sys_get_temp_dir() . '/Series-Name_Series-01_episode-title-01-metadata.txt\' -c copy -map_metadata 1'
. ' -metadata Title=\'01 - Episode Title\''
. ' \'Series-Name/Series-01/10-episode title.mp4\'',
$command->getCommandLine()
@ -250,19 +255,21 @@ class CuttingTest extends TestCase
*/
public function generatesCommandForCleanup(): void
{
$video = $this->prophesize(VideoInfo::class);
$video->getTargetFilePath()->willReturn('Series-Name/Series-01/10-episode title.mp4');
$video->getOriginalFilenameWithSuffix('concat')->willReturn('Series-Name_Series-01_episode-title-01-concat.mp4');
$video->getOriginalFilenameWithSuffix('metadata')->willReturn('Series-Name_Series-01_episode-title-01-metadata.mp4');
$video = $this->createStub(VideoInfo::class);
$video->method('getTargetFilePath')->willReturn('Series-Name/Series-01/10-episode title.mp4');
$video->method('getOriginalFilenameWithSuffix')->willReturnOnConsecutiveCalls(
'Series-Name_Series-01_episode-title-01-concat.mp4',
'Series-Name_Series-01_episode-title-01-metadata.mp4'
);
$subject = new Cutting(
$video->reveal()
$video
);
$command = $subject->getCommandForCleanup();
static::assertSame(
'rm \'/tmp/Series-Name_Series-01_episode-title-01-concat.txt\' \'/tmp/Series-Name_Series-01_episode-title-01-metadata.txt\'',
'rm \'' . sys_get_temp_dir() . '/Series-Name_Series-01_episode-title-01-concat.txt\' \'' . sys_get_temp_dir() . '/Series-Name_Series-01_episode-title-01-metadata.txt\'',
$command->getCommandLine()
);
}
@ -272,18 +279,20 @@ class CuttingTest extends TestCase
*/
public function generatesCommandForCleanupWithSingleTempFile(): void
{
$video = $this->prophesize(VideoInfo::class);
$video->getStart()->willReturn('10.05.20');
$video->getEnd()->willReturn('13.10.25');
$video->getAds()->willReturn([]);
$video->getOriginalFilename()->willReturn('Some-Video.mp4');
$video->getTargetFilePath()->willReturn('Series-Name/Series-01/10-episode title.mp4');
$video->getOriginalFilenameWithSuffix('cut-1')->willReturn('Some-Video-cut-1.mp4');
$video->getOriginalFilenameWithSuffix('concat')->willReturn('Series-Name_Series-01_episode-title-01-concat.mp4');
$video->getOriginalFilenameWithSuffix('metadata')->willReturn('Series-Name_Series-01_episode-title-01-metadata.mp4');
$video = $this->createStub(VideoInfo::class);
$video->method('getStart')->willReturn('10.05.20');
$video->method('getEnd')->willReturn('13.10.25');
$video->method('getAds')->willReturn([]);
$video->method('getOriginalFilename')->willReturn('Some-Video.mp4');
$video->method('getTargetFilePath')->willReturn('Series-Name/Series-01/10-episode title.mp4');
$video->method('getOriginalFilenameWithSuffix')->willReturnOnConsecutiveCalls(
'Some-Video-cut-1.mp4',
'Series-Name_Series-01_episode-title-01-concat.mp4',
'Series-Name_Series-01_episode-title-01-metadata.mp4'
);
$subject = new Cutting(
$video->reveal()
$video
);
foreach ($subject->getCommandsForCutting() as $command) {
@ -293,7 +302,7 @@ class CuttingTest extends TestCase
$command = $subject->getCommandForCleanup();
static::assertSame(
'rm \'/tmp/Some-Video-cut-1.mp4\' \'/tmp/Series-Name_Series-01_episode-title-01-concat.txt\' \'/tmp/Series-Name_Series-01_episode-title-01-metadata.txt\'',
'rm \'' . sys_get_temp_dir() . '/Some-Video-cut-1.mp4\' \'' . sys_get_temp_dir() . '/Series-Name_Series-01_episode-title-01-concat.txt\' \'' . sys_get_temp_dir() . '/Series-Name_Series-01_episode-title-01-metadata.txt\'',
$command->getCommandLine()
);
}

View file

@ -190,7 +190,7 @@ class VideoInfoTest extends TestCase
);
}
public function possibleFilenames(): array
public static function possibleFilenames(): array
{
return [
'Movie' => [