feat: analyse import + all tests fixed
This commit is contained in:
parent
fbe9619224
commit
3170a7c60e
@@ -19,7 +19,9 @@ class InMemoryMangaRepository implements MangaRepositoryInterface
|
||||
'A test manga description',
|
||||
'Test Author',
|
||||
'2024',
|
||||
[] // Pas de sources préférées par défaut
|
||||
false, // monitored
|
||||
[], // preferredSources
|
||||
[] // alternativeSlugs
|
||||
);
|
||||
|
||||
// Ajoute un manga avec des sources préférées pour les tests
|
||||
@@ -30,7 +32,9 @@ class InMemoryMangaRepository implements MangaRepositoryInterface
|
||||
'A test manga with preferred sources',
|
||||
'Test Author',
|
||||
'2024',
|
||||
['test-source'] // Une source préférée
|
||||
false, // monitored
|
||||
['test-source'], // preferredSources
|
||||
[] // alternativeSlugs
|
||||
);
|
||||
}
|
||||
|
||||
@@ -55,7 +59,9 @@ class InMemoryMangaRepository implements MangaRepositoryInterface
|
||||
$manga->getDescription(),
|
||||
$manga->getAuthor(),
|
||||
$manga->getPublicationYear(),
|
||||
$sourceIds // Mise à jour des sources préférées
|
||||
$manga->isMonitored(), // monitored
|
||||
$sourceIds, // preferredSources
|
||||
$manga->getAlternativeSlugs() // alternativeSlugs
|
||||
);
|
||||
$this->mangas[$mangaId] = $updatedManga;
|
||||
}
|
||||
|
||||
60
tests/Domain/Scraping/Adapter/InMemoryScraperFactory.php
Normal file
60
tests/Domain/Scraping/Adapter/InMemoryScraperFactory.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Domain\Scraping\Adapter;
|
||||
|
||||
use App\Domain\Scraping\Domain\Contract\Service\ScraperFactoryInterface;
|
||||
use App\Domain\Scraping\Domain\Contract\Service\ScraperInterface;
|
||||
|
||||
class InMemoryScraperFactory implements ScraperFactoryInterface
|
||||
{
|
||||
/** @var array<string, ScraperInterface> */
|
||||
private array $scrapers = [];
|
||||
|
||||
public function createScraper(string $source): ScraperInterface
|
||||
{
|
||||
if (!isset($this->scrapers[$source])) {
|
||||
$this->scrapers[$source] = new InMemoryScraperAdapter();
|
||||
}
|
||||
|
||||
return $this->scrapers[$source];
|
||||
}
|
||||
|
||||
public function getBestScraper(): ScraperInterface
|
||||
{
|
||||
return $this->createScraper('best');
|
||||
}
|
||||
|
||||
public function getFallbackScraper(): ScraperInterface
|
||||
{
|
||||
return $this->createScraper('fallback');
|
||||
}
|
||||
|
||||
public function getScraperWithFallback(string $preferredType): ScraperInterface
|
||||
{
|
||||
if (isset($this->scrapers[$preferredType])) {
|
||||
return $this->scrapers[$preferredType];
|
||||
}
|
||||
|
||||
return $this->getFallbackScraper();
|
||||
}
|
||||
|
||||
public function getSupportedTypes(): array
|
||||
{
|
||||
return array_keys($this->scrapers);
|
||||
}
|
||||
|
||||
public function isSupported(string $type): bool
|
||||
{
|
||||
return isset($this->scrapers[$type]);
|
||||
}
|
||||
|
||||
public function addScraper(string $source, ScraperInterface $scraper): void
|
||||
{
|
||||
$this->scrapers[$source] = $scraper;
|
||||
}
|
||||
|
||||
public function clear(): void
|
||||
{
|
||||
$this->scrapers = [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user