feat: analyse import + all tests fixed
This commit is contained in:
parent
fbe9619224
commit
3170a7c60e
@@ -4,28 +4,29 @@ namespace App\Tests\Domain\Manga\Application\CommandHandler;
|
||||
|
||||
use App\Domain\Manga\Application\Command\FetchMangaChapters;
|
||||
use App\Domain\Manga\Application\CommandHandler\FetchMangaChaptersHandler;
|
||||
use App\Domain\Manga\Domain\Exception\MangadexApiException;
|
||||
use App\Domain\Manga\Domain\Model\Manga;
|
||||
use App\Domain\Manga\Domain\Model\ValueObject\ExternalId;
|
||||
use App\Domain\Manga\Domain\Model\ValueObject\MangaId;
|
||||
use App\Domain\Manga\Domain\Model\ValueObject\MangaSlug;
|
||||
use App\Domain\Manga\Domain\Model\ValueObject\MangaTitle;
|
||||
use App\Tests\Domain\Manga\Adapter\InMemoryMangadexClient;
|
||||
use App\Tests\Domain\Manga\Adapter\InMemoryChapterSynchronizationService;
|
||||
use App\Tests\Domain\Manga\Adapter\InMemoryMangaRepository;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FetchMangaChaptersHandlerTest extends TestCase
|
||||
{
|
||||
private InMemoryMangadexClient $mangadexClient;
|
||||
private InMemoryChapterSynchronizationService $chapterSynchronizationService;
|
||||
private InMemoryMangaRepository $mangaRepository;
|
||||
private FetchMangaChaptersHandler $handler;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->mangadexClient = new InMemoryMangadexClient();
|
||||
$this->chapterSynchronizationService = new InMemoryChapterSynchronizationService();
|
||||
$this->mangaRepository = new InMemoryMangaRepository();
|
||||
$this->handler = new FetchMangaChaptersHandler(
|
||||
$this->mangadexClient,
|
||||
$this->mangaRepository
|
||||
$this->mangaRepository,
|
||||
$this->chapterSynchronizationService
|
||||
);
|
||||
}
|
||||
|
||||
@@ -47,22 +48,12 @@ class FetchMangaChaptersHandlerTest extends TestCase
|
||||
|
||||
$this->mangaRepository->save($manga);
|
||||
|
||||
$this->mangadexClient->addFeed($externalId, [
|
||||
[
|
||||
'id' => 'chapter-1',
|
||||
'attributes' => [
|
||||
'chapter' => '1',
|
||||
'title' => 'Chapter 1',
|
||||
'volume' => '1',
|
||||
'translatedLanguage' => 'fr'
|
||||
]
|
||||
]
|
||||
]);
|
||||
|
||||
$command = new FetchMangaChapters($mangaId);
|
||||
$command = new FetchMangaChapters(new MangaId($mangaId));
|
||||
$this->handler->handle($command);
|
||||
|
||||
$this->assertCount(1, $this->mangaRepository->getSavedChapters());
|
||||
$synchronizedChapters = $this->chapterSynchronizationService->getSynchronizedChapters();
|
||||
$this->assertCount(1, $synchronizedChapters);
|
||||
$this->assertArrayHasKey($mangaId, $synchronizedChapters);
|
||||
}
|
||||
|
||||
public function testHandleWithNonExistingManga(): void
|
||||
@@ -72,7 +63,7 @@ class FetchMangaChaptersHandlerTest extends TestCase
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->expectExceptionMessage('Manga not found');
|
||||
|
||||
$command = new FetchMangaChapters($mangaId);
|
||||
$command = new FetchMangaChapters(new MangaId($mangaId));
|
||||
$this->handler->handle($command);
|
||||
}
|
||||
|
||||
@@ -93,10 +84,10 @@ class FetchMangaChaptersHandlerTest extends TestCase
|
||||
|
||||
$this->mangaRepository->save($manga);
|
||||
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->expectExceptionMessage('Manga has no external ID');
|
||||
$this->expectException(MangadexApiException::class);
|
||||
$this->expectExceptionMessage('Manga has no external_id');
|
||||
|
||||
$command = new FetchMangaChapters($mangaId);
|
||||
$command = new FetchMangaChapters(new MangaId($mangaId));
|
||||
$this->handler->handle($command);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user