mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Update additional postprocessing code
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\AdditionalProcessing;
|
||||
|
||||
use App\Services\AdditionalProcessing\ArchiveExtractionService;
|
||||
use dariusiii\rarinfo\ArchiveInfo;
|
||||
use dariusiii\rarinfo\Par2Info;
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ArchiveExtractionServiceTest extends TestCase
|
||||
{
|
||||
use CreatesProcessingConfiguration;
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
Mockery::close();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function it_returns_file_data_directly_from_archive_info_when_available(): void
|
||||
{
|
||||
$archiveInfo = Mockery::mock(ArchiveInfo::class);
|
||||
$archiveInfo->shouldReceive('setData')->once()->with('ARCHIVE', true)->andReturn(true);
|
||||
$archiveInfo->shouldReceive('getFileData')->once()->with('cover.jpg')->andReturn('IMAGE-DATA');
|
||||
|
||||
$service = new ArchiveExtractionService(
|
||||
$this->makeConfig(),
|
||||
$archiveInfo,
|
||||
Mockery::mock(Par2Info::class)
|
||||
);
|
||||
|
||||
$this->assertSame('IMAGE-DATA', $service->extractSpecificFile('ARCHIVE', 'cover.jpg', sys_get_temp_dir().'/'));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function it_detects_common_standalone_video_signatures(): void
|
||||
{
|
||||
$service = new ArchiveExtractionService(
|
||||
$this->makeConfig(),
|
||||
Mockery::mock(ArchiveInfo::class),
|
||||
Mockery::mock(Par2Info::class)
|
||||
);
|
||||
|
||||
$avi = 'RIFF'.str_repeat("\0", 4).'AVI '.str_repeat("\0", 16);
|
||||
$mp4 = str_repeat("\0", 4).'ftypisom'.str_repeat("\0", 16);
|
||||
|
||||
$this->assertSame('avi', $service->detectStandaloneVideo($avi));
|
||||
$this->assertSame('mp4', $service->detectStandaloneVideo($mp4));
|
||||
$this->assertNull($service->detectStandaloneVideo('tiny'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user