Daniel Siepmann
2d411d7160
This allows to auto scrap info for tv show episodes from movie database on kodi.
214 lines
5.3 KiB
PHP
214 lines
5.3 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
|
|
*/
|
|
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());
|
|
}
|
|
|
|
/**
|
|
* @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')
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
* @dataProvider possibleFilenames
|
|
*/
|
|
public function returnsHumanTitle(
|
|
string $filename,
|
|
string $expectedTargetFilePath
|
|
): void {
|
|
$subject = new VideoInfo(
|
|
$filename,
|
|
'05:20.1',
|
|
'32:30.30',
|
|
[]
|
|
);
|
|
|
|
$file = new \SplFileInfo($expectedTargetFilePath);
|
|
|
|
static::assertSame(
|
|
$file->getBasename('.' . $file->getExtension()),
|
|
$subject->getTitleForHumans()
|
|
);
|
|
}
|
|
|
|
public static 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 without episode' => [
|
|
'filename' => 'Storage-Hunters_episode-2_trucker-auktion_hq.mp4',
|
|
'expectedTargetFilePath' => 'Storage-Hunters/E02 - Trucker Auktion.mp4',
|
|
],
|
|
'Series with seasons without episode' => [
|
|
'filename' => 'The-Big-Bang-Theory_season-1_episode-12_das-jerusalem-projekt_hq.mp4',
|
|
'expectedTargetFilePath' => 'The-Big-Bang-Theory/Staffel-01/S01E12 - Das Jerusalem Projekt.mp4',
|
|
],
|
|
'Series with seasons and episode' => [
|
|
'filename' => 'The-Big-Bang-Theory_season-1_episode-12_das-jerusalem-projekt_hq.mp4',
|
|
'expectedTargetFilePath' => 'The-Big-Bang-Theory/Staffel-01/S01E12 - Das Jerusalem Projekt.mp4',
|
|
],
|
|
];
|
|
}
|
|
}
|