feat: analyse import + all tests fixed
This commit is contained in:
parent
fbe9619224
commit
3170a7c60e
@@ -13,7 +13,7 @@ use App\Domain\Manga\Domain\Model\ValueObject\MangaTitle;
|
||||
use App\Tests\Domain\Manga\Adapter\InMemoryMangaProvider;
|
||||
use App\Tests\Domain\Manga\Adapter\InMemoryMangaRepository;
|
||||
use App\Tests\Domain\Manga\Adapter\InMemoryImageProcessor;
|
||||
use App\Tests\Shared\Adapter\InMemoryMessageBus;
|
||||
use App\Tests\Shared\Adapter\InMemoryEventDispatcher;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CreateMangaFromMangadexHandlerTest extends TestCase
|
||||
@@ -22,7 +22,7 @@ class CreateMangaFromMangadexHandlerTest extends TestCase
|
||||
private InMemoryMangaRepository $repository;
|
||||
private InMemoryImageProcessor $imageProcessor;
|
||||
private CreateMangaFromMangadexHandler $handler;
|
||||
private InMemoryMessageBus $messageBus;
|
||||
private InMemoryEventDispatcher $eventDispatcher;
|
||||
protected function setUp(): void
|
||||
{
|
||||
$manga = new Manga(
|
||||
@@ -41,12 +41,12 @@ class CreateMangaFromMangadexHandlerTest extends TestCase
|
||||
$this->provider = new InMemoryMangaProvider([$manga]);
|
||||
$this->repository = new InMemoryMangaRepository();
|
||||
$this->imageProcessor = new InMemoryImageProcessor();
|
||||
$this->messageBus = new InMemoryMessageBus();
|
||||
$this->eventDispatcher = new InMemoryEventDispatcher();
|
||||
$this->handler = new CreateMangaFromMangadexHandler(
|
||||
$this->provider,
|
||||
$this->repository,
|
||||
$this->imageProcessor,
|
||||
$this->messageBus
|
||||
$this->eventDispatcher
|
||||
);
|
||||
}
|
||||
|
||||
@@ -76,4 +76,4 @@ class CreateMangaFromMangadexHandlerTest extends TestCase
|
||||
// Act
|
||||
$this->handler->handle($command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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