52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Domain\Scraping\Adapter;
|
|
|
|
use App\Domain\Scraping\Domain\Contract\Repository\MangaRepositoryInterface;
|
|
use App\Domain\Scraping\Domain\Model\Manga;
|
|
|
|
class InMemoryMangaRepository implements MangaRepositoryInterface
|
|
{
|
|
private array $mangas = [];
|
|
|
|
public function __construct()
|
|
{
|
|
// Ajoute un manga par défaut pour les tests
|
|
$this->mangas['test-manga'] = new Manga(
|
|
'test-manga',
|
|
'Test Manga',
|
|
'test-manga',
|
|
'A test manga description',
|
|
'Test Author',
|
|
'2024',
|
|
[] // Pas de sources préférées par défaut
|
|
);
|
|
|
|
// Ajoute un manga avec des sources préférées pour les tests
|
|
$this->mangas['test-manga-with-sources'] = new Manga(
|
|
'test-manga-with-sources',
|
|
'Test Manga With Sources',
|
|
'test-manga-with-sources',
|
|
'A test manga with preferred sources',
|
|
'Test Author',
|
|
'2024',
|
|
['test-source'] // Une source préférée
|
|
);
|
|
}
|
|
|
|
public function getById(string $id): ?Manga
|
|
{
|
|
return $this->mangas[$id] ?? null;
|
|
}
|
|
|
|
public function save(Manga $manga): void
|
|
{
|
|
$this->mangas[$manga->getId()] = $manga;
|
|
}
|
|
|
|
public function clear(): void
|
|
{
|
|
$this->mangas = [];
|
|
}
|
|
}
|