feat: Reader beginning
This commit is contained in:
parent
e90c0a140e
commit
55945adc53
31
tests/Domain/Scraping/Adapter/InMemoryChapterRepository.php
Normal file
31
tests/Domain/Scraping/Adapter/InMemoryChapterRepository.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Domain\Scraping\Adapter;
|
||||
|
||||
use App\Domain\Scraping\Domain\Contract\Repository\ChapterRepositoryInterface;
|
||||
use App\Domain\Scraping\Domain\Model\Chapter;
|
||||
|
||||
class InMemoryChapterRepository implements ChapterRepositoryInterface
|
||||
{
|
||||
private array $chapters = [];
|
||||
public function getByMangaIdAndChapterNumber(string $mangaId, int $chapterNumber): Chapter
|
||||
{
|
||||
foreach ($this->chapters as $chapter) {
|
||||
if ($chapter->mangaId === $mangaId && $chapter->chapterNumber === $chapterNumber) {
|
||||
return $chapter;
|
||||
}
|
||||
}
|
||||
|
||||
throw new \RuntimeException('Chapter not found');
|
||||
}
|
||||
|
||||
public function save(Chapter $chapter): void
|
||||
{
|
||||
$this->chapters[$chapter->id] = $chapter;
|
||||
}
|
||||
|
||||
public function clear(): void
|
||||
{
|
||||
$this->chapters = [];
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\Tests\Domain\Scraping\Adapter;
|
||||
|
||||
use App\Domain\Scraping\Domain\Contract\Service\ScraperInterface;
|
||||
use App\Domain\Scraping\Domain\Model\ScrapingJob;
|
||||
use App\Domain\Scraping\Domain\Model\ValueObject\CbzPath;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
class InMemoryScraperAdapter implements ScraperInterface
|
||||
@@ -18,6 +19,7 @@ class InMemoryScraperAdapter implements ScraperInterface
|
||||
}
|
||||
|
||||
$job->complete();
|
||||
$job->cbzPath = new CbzPath('/path/to/test.cbz');
|
||||
return $job;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class InMemoryScrapingJobRepository implements ScrapingJobRepositoryInterface
|
||||
public function findByChapterId(string $chapterId): ?ScrapingJob
|
||||
{
|
||||
foreach (self::$jobs as $job) {
|
||||
if ($job->getChapterId() === $chapterId) {
|
||||
if ($job->getId() === $chapterId) {
|
||||
return $job;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user