Files
Mangarr/tests/Domain/Shared/Application/CommandHandler/DeleteJobHandlerTest.php
ext.jeremy.guillot@maxicoffee.domains 19395b4869 feat: activity page
2026-03-11 20:54:55 +01:00

42 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Tests\Domain\Shared\Application\CommandHandler;
use App\Domain\Scraping\Domain\Model\ScrapingJob;
use App\Domain\Shared\Application\Command\DeleteJob;
use App\Domain\Shared\Application\CommandHandler\DeleteJobHandler;
use App\Domain\Shared\Domain\Exception\JobNotFoundException;
use App\Tests\Domain\Shared\Adapter\InMemoryJobRepository;
use PHPUnit\Framework\TestCase;
class DeleteJobHandlerTest extends TestCase
{
private InMemoryJobRepository $repository;
private DeleteJobHandler $handler;
protected function setUp(): void
{
$this->repository = new InMemoryJobRepository();
$this->handler = new DeleteJobHandler($this->repository);
}
public function test_it_deletes_existing_job(): void
{
$job = new ScrapingJob('job-1', 'manga-1', 1.0, 'source-1');
$this->repository->save($job);
$this->handler->handle(new DeleteJob('job-1'));
$this->assertNull($this->repository->get('job-1'));
}
public function test_it_throws_when_job_not_found(): void
{
$this->expectException(JobNotFoundException::class);
$this->handler->handle(new DeleteJob('non-existent-id'));
}
}