From cca776dbebeea28ee031a52e94c886fb24ef66d5 Mon Sep 17 00:00:00 2001 From: Noah Lancien Date: Mon, 26 Oct 2026 17:02:07 +0100 Subject: [PATCH] fix: :recycle: Remove generic failed output for US2.1 --- .../UseCases/Campaign/Create/CreateCampaign.php | 5 ++--- .../Create/Outputs/CampaignCreationFailed.php | 15 --------------- .../Create/Outputs/CampaignNameAlreadyExists.php | 11 +++++++++++ .../Create/Outputs/CreateCampaignError.php | 11 ----------- .../Campaign/Create/CreateCampaignTest.php | 8 +++----- 5 files changed, 16 insertions(+), 34 deletions(-) delete mode 100644 src/Application/UseCases/Campaign/Create/Outputs/CampaignCreationFailed.php create mode 100644 src/Application/UseCases/Campaign/Create/Outputs/CampaignNameAlreadyExists.php delete mode 100644 src/Application/UseCases/Campaign/Create/Outputs/CreateCampaignError.php diff --git a/src/Application/UseCases/Campaign/Create/CreateCampaign.php b/src/Application/UseCases/Campaign/Create/CreateCampaign.php index fd7525a..6d8ff11 100644 --- a/src/Application/UseCases/Campaign/Create/CreateCampaign.php +++ b/src/Application/UseCases/Campaign/Create/CreateCampaign.php @@ -5,8 +5,7 @@ declare(strict_types=1); namespace Application\UseCases\Campaign\Create; use Application\UseCases\Campaign\Create\Outputs\CampaignCreated; -use Application\UseCases\Campaign\Create\Outputs\CampaignCreationFailed; -use Application\UseCases\Campaign\Create\Outputs\CreateCampaignError; +use Application\UseCases\Campaign\Create\Outputs\CampaignNameAlreadyExists; use Domain\Models\Entities\Campaign; use Domain\Ports\Repositories\CampaignRepository; use Shared\DDD\UseCases\Input as BaseInput; @@ -29,7 +28,7 @@ final readonly class CreateCampaign implements UseCase, Transactional Assert::isInstanceOf($input, Input::class); if ($this->repository->existsByName($input->name)) { - return new CampaignCreationFailed(CreateCampaignError::CampaignNameAlreadyExists); + return new CampaignNameAlreadyExists(); } $campaign = Campaign::create( diff --git a/src/Application/UseCases/Campaign/Create/Outputs/CampaignCreationFailed.php b/src/Application/UseCases/Campaign/Create/Outputs/CampaignCreationFailed.php deleted file mode 100644 index bdb51f8..0000000 --- a/src/Application/UseCases/Campaign/Create/Outputs/CampaignCreationFailed.php +++ /dev/null @@ -1,15 +0,0 @@ - new Input(...array_merge([ @@ -72,7 +71,6 @@ describe('create campaign use case', function (): void { $result = $useCase->execute($input); // THEN - expect($result)->toBeInstanceOf(CampaignCreationFailed::class) - ->and($result->error)->toBe(CreateCampaignError::CampaignNameAlreadyExists); + expect($result)->toBeInstanceOf(CampaignNameAlreadyExists::class); }); });