videocutting/tests/Unit/VideoInfoTest.php

188 lines
4.5 KiB
PHP
Raw Normal View History

2020-09-30 11:46:41 +02:00
<?php
namespace DanielSiepmann\Videcutting\Tests\Unit;
/*
* Copyright (C) 2020 Daniel Siepmann <coding@daniel-siepmann.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
use DanielSiepmann\Videcutting\VideoInfo;
use PHPUnit\Framework\TestCase;
/**
* @covers DanielSiepmann\Videcutting\VideoInfo
*/
class VideoInfoTest extends TestCase
{
/**
* @test
*/
public function instanceCanBeCreated(): void
{
$subject = new VideoInfo(
'Example-Video-File.mp4',
'05:20.1',
'32:30.30',
[]
2020-09-30 11:46:41 +02:00
);
static::assertInstanceOf(VideoInfo::class, $subject);
}
/**
* @test
*/
public function getInitialSetStart()
{
$subject = new VideoInfo(
'Example-Video-File.mp4',
'05:20.1',
'32:30.30',
[]
);
static::assertSame('05:20.1', $subject->getStart());
}
/**
* @test
*/
public function getInitialSetEnd()
{
$subject = new VideoInfo(
'Example-Video-File.mp4',
'05:20.1',
'32:30.30',
[]
);
static::assertSame('32:30.30', $subject->getEnd());
}
/**
* @test
*/
public function getInitialEmptySetAds()
{
$subject = new VideoInfo(
'Example-Video-File.mp4',
'05:20.1',
'32:30.30',
[]
);
static::assertSame([], $subject->getAds());
}
/**
* @test
*/
public function getInitialSetAds()
{
$subject = new VideoInfo(
'Example-Video-File.mp4',
'05:20.1',
'32:30.30',
[
'10:35/15:10',
'21:38/31:02',
]
);
static::assertSame([
['10:35', '15:10'],
['21:38', '31:02'],
], $subject->getAds());
}
2020-09-30 11:46:41 +02:00
/**
* @test
* @dataProvider possibleFilenames
*/
public function returnsTargetFilePath(
string $filename,
string $expectedTargetFilePath
): void {
$subject = new VideoInfo(
$filename,
'05:20.1',
'32:30.30',
[]
2020-09-30 11:46:41 +02:00
);
static::assertSame(
$expectedTargetFilePath,
$subject->getTargetFilePath()
);
}
/**
* @test
*/
public function returnsOriginalFilename(): void
{
$subject = new VideoInfo(
'Example-Video-File.mp4',
'05:20.1',
'32:30.30',
[]
2020-09-30 11:46:41 +02:00
);
static::assertSame(
'Example-Video-File.mp4',
$subject->getOriginalFilename()
);
}
/**
* @test
*/
public function returnsOriginalFilenameWithProvidedSuffix(): void
{
$subject = new VideoInfo(
'Example-Video-File.mp4',
'05:20.1',
'32:30.30',
[]
2020-09-30 11:46:41 +02:00
);
static::assertSame(
'Example-Video-File-some-suffix.mp4',
$subject->getOriginalFilenameWithSuffix('some-suffix')
);
}
public function possibleFilenames(): array
{
return [
'Movie' => [
'filename' => 'Sherlock-Holmes_Der-Vampir-Von-Whitechapel_hq.mp4',
'expectedTargetFilePath' => 'Sherlock-Holmes/Der Vampir Von Whitechapel.mp4',
],
'Series no seasons' => [
'filename' => 'Storage-Hunters_episode-2_trucker-auktion_hq.mp4',
'expectedTargetFilePath' => 'Storage-Hunters/02-Trucker Auktion.mp4',
],
'Series with seasons' => [
'filename' => 'The-Big-Bang-Theory_season-1_episode-12_das-jerusalem-projekt_hq.mp4',
'expectedTargetFilePath' => 'The-Big-Bang-Theory/Staffel-01/12-Das Jerusalem Projekt.mp4',
],
];
}
}