feat: scraping endpoints, job persistence, firsts unit tests, legacy entities usage
This commit is contained in:
parent
c55cd62ec7
commit
0374ab0e46
@@ -33,14 +33,14 @@ class ScrapeChapterHandlerTest extends TestCase
|
||||
public function testHandleSuccessfully(): void
|
||||
{
|
||||
$command = new ScrapeChapter(
|
||||
chapterId: 2,
|
||||
mangaId: 1,
|
||||
chapterNumber: 2,
|
||||
sourceId: 3,
|
||||
mangaId: 1
|
||||
);
|
||||
|
||||
$this->handler->handle($command);
|
||||
|
||||
$scrapingJobs = $this->scraper->getJobs();
|
||||
$scrapingJobs = $this->repository->getJobs();
|
||||
$this->assertCount(1, $scrapingJobs);
|
||||
$job = $scrapingJobs[0];
|
||||
|
||||
@@ -57,9 +57,9 @@ class ScrapeChapterHandlerTest extends TestCase
|
||||
public function testHandleThrowsException(): void
|
||||
{
|
||||
$command = new ScrapeChapter(
|
||||
chapterId: 2,
|
||||
mangaId: 1,
|
||||
chapterNumber: 2,
|
||||
sourceId: 3,
|
||||
mangaId: 1
|
||||
);
|
||||
|
||||
$exception = new \Exception('Scraping failed');
|
||||
@@ -72,10 +72,11 @@ class ScrapeChapterHandlerTest extends TestCase
|
||||
$this->handler->handle($command);
|
||||
} finally {
|
||||
$dispatchedMessages = $this->eventBus->getDispatchedMessages();
|
||||
$this->assertCount(1, $dispatchedMessages);
|
||||
$this->assertInstanceOf(ChapterScrapingFailed::class, $dispatchedMessages[0]);
|
||||
$this->assertEquals(2, $dispatchedMessages[0]->getChapterId());
|
||||
$this->assertEquals('Scraping failed', $dispatchedMessages[0]->getReason());
|
||||
$this->assertCount(2, $dispatchedMessages);
|
||||
$this->assertInstanceOf(ChapterScrapingStarted::class, $dispatchedMessages[0]);
|
||||
$this->assertInstanceOf(ChapterScrapingFailed::class, $dispatchedMessages[1]);
|
||||
$this->assertEquals(2, $dispatchedMessages[1]->getChapterNumber());
|
||||
$this->assertEquals('Scraping failed', $dispatchedMessages[1]->getReason());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user