fix: more patterns

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-10-16 14:35:58 +02:00
parent 50b33f53d7
commit 9e7f7b4cfc
2 changed files with 84 additions and 0 deletions

View File

@@ -233,4 +233,64 @@ class FilenameAnalyzerTest extends TestCase
"Should not have volume for: {$case['filename']}");
}
}
public function test_it_handles_full_dash_patterns(): void
{
$testCases = [
[
'filename' => 'berserk-volume-42.cbz',
'expectedTitle' => 'berserk',
'expectedVolume' => 42.0,
],
[
'filename' => 'berserk-chapter-100.cbz',
'expectedTitle' => 'berserk',
'expectedChapter' => 100.0,
],
[
'filename' => 'berserk-chapitre-100.cbz',
'expectedTitle' => 'berserk',
'expectedChapter' => 100.0,
],
[
'filename' => 'berserk-volume-42-chapter-100.cbz',
'expectedTitle' => 'berserk',
'expectedVolume' => 42.0,
'expectedChapter' => 100.0,
],
[
'filename' => 'berserk-chapitre-100-volume-42.cbz',
'expectedTitle' => 'berserk',
'expectedVolume' => 42.0,
'expectedChapter' => 100.0,
],
];
foreach ($testCases as $case) {
$result = $this->analyzer->analyze($case['filename']);
$this->assertEquals($case['expectedTitle'], $result->getTitle()->getValue(),
"Failed title extraction for: {$case['filename']}");
if (isset($case['expectedVolume'])) {
$this->assertTrue($result->hasVolumeNumber(),
"Should have volume for: {$case['filename']}");
$this->assertEquals($case['expectedVolume'], $result->getVolumeNumber()->getValue(),
"Failed volume extraction for: {$case['filename']}");
} else {
$this->assertFalse($result->hasVolumeNumber(),
"Should not have volume for: {$case['filename']}");
}
if (isset($case['expectedChapter'])) {
$this->assertTrue($result->hasChapterNumber(),
"Should have chapter for: {$case['filename']}");
$this->assertEquals($case['expectedChapter'], $result->getChapterNumber()->getValue(),
"Failed chapter extraction for: {$case['filename']}");
} else {
$this->assertFalse($result->hasChapterNumber(),
"Should not have chapter for: {$case['filename']}");
}
}
}
}