117 lines
3.2 KiB
PHP
117 lines
3.2 KiB
PHP
<?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'
|
|
);
|
|
|
|
static::assertInstanceOf(VideoInfo::class, $subject);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
* @dataProvider possibleFilenames
|
|
*/
|
|
public function returnsTargetFilePath(
|
|
string $filename,
|
|
string $expectedTargetFilePath
|
|
): void {
|
|
$subject = new VideoInfo(
|
|
$filename,
|
|
'05:20.1',
|
|
'32:30.30'
|
|
);
|
|
|
|
static::assertSame(
|
|
$expectedTargetFilePath,
|
|
$subject->getTargetFilePath()
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function returnsOriginalFilename(): void
|
|
{
|
|
$subject = new VideoInfo(
|
|
'Example-Video-File.mp4',
|
|
'05:20.1',
|
|
'32:30.30'
|
|
);
|
|
|
|
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'
|
|
);
|
|
|
|
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',
|
|
],
|
|
];
|
|
}
|
|
}
|