feat: analyse import + all tests fixed
This commit is contained in:
parent
fbe9619224
commit
3170a7c60e
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Domain\Manga\Adapter;
|
||||
|
||||
use App\Domain\Manga\Domain\Contract\Service\ChapterSynchronizationServiceInterface;
|
||||
use App\Domain\Manga\Domain\Model\Manga;
|
||||
|
||||
class InMemoryChapterSynchronizationService implements ChapterSynchronizationServiceInterface
|
||||
{
|
||||
/** @var array<string, array> */
|
||||
private array $synchronizedChapters = [];
|
||||
|
||||
public function synchronizeChapters(Manga $manga): array
|
||||
{
|
||||
$this->synchronizedChapters[$manga->getId()->getValue()] = [
|
||||
'manga_id' => $manga->getId()->getValue(),
|
||||
'external_id' => $manga->getExternalId()?->getValue(),
|
||||
'synchronized_at' => new \DateTimeImmutable()
|
||||
];
|
||||
|
||||
// Retourne les IDs des chapitres synchronisés (simulation)
|
||||
return ['chapter-1', 'chapter-2'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array>
|
||||
*/
|
||||
public function getSynchronizedChapters(): array
|
||||
{
|
||||
return $this->synchronizedChapters;
|
||||
}
|
||||
|
||||
public function clear(): void
|
||||
{
|
||||
$this->synchronizedChapters = [];
|
||||
}
|
||||
}
|
||||
@@ -128,13 +128,14 @@ class InMemoryMangaRepository implements MangaRepositoryInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
public function saveChapter(Chapter $chapter): void
|
||||
public function saveChapter(Chapter $chapter): ChapterId
|
||||
{
|
||||
$this->savedChapters[] = $chapter;
|
||||
if (!isset($this->chapters[$chapter->getMangaId()])) {
|
||||
$this->chapters[$chapter->getMangaId()] = [];
|
||||
}
|
||||
$this->chapters[$chapter->getMangaId()][] = $chapter;
|
||||
return new ChapterId($chapter->getId());
|
||||
}
|
||||
|
||||
/** @return array<Chapter> */
|
||||
@@ -160,6 +161,11 @@ class InMemoryMangaRepository implements MangaRepositoryInterface
|
||||
$manga->getDescription()
|
||||
];
|
||||
|
||||
// Ajouter les slugs alternatifs aux champs de recherche
|
||||
foreach ($manga->getAlternativeSlugs() as $altSlug) {
|
||||
$searchableFields[] = $altSlug;
|
||||
}
|
||||
|
||||
foreach ($searchableFields as $field) {
|
||||
if (str_contains(strtolower($field), strtolower($query))) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user