input = new Input( brandCode: new BrandCode('AAA01'), name: new CampaignName('Campaign name'), applicant: new Applicant('John', 'Doe', new Email('john.doe@example.com')), campaignType: CampaignRequestType::CLUB, requestedCoupon: new RequestedCoupon( name: new CouponName('Coupon A'), quantity: new RequestedCouponQuantity(100), diffusion: new Period(new DateTime('2026-01-01'), new DateTime('2026-02-01')), moneyAmount: new MoneyAmount(new Money(Currency::EUR, 300)), processingCode: new ProcessingCode('PC1'), couponValidity: new CouponValidity(30, new DateTime('2026-02-01')), couponValidityInformation: [ new CouponValidityInformation('Lorem ipsum dolor sit amet consectetur adipiscing elit.', Country::FRANCE), ], products: [new IncoCode(35784), new IncoCode(15522)], printRules: new PrintRules(maxPerCustomer: 3) ), ); }); describe('create campaign request use case', function (): void { it('creates a campaign request when the brand exists', function (): void { // GIVEN $brandRepository = \Mockery::mock(BrandRepository::class); $brandRepository->shouldReceive('existsByCode')->once()->with($this->input->brandCode)->andReturn(true); $campaignRequestRepository = \Mockery::mock(CampaignRequestRepository::class); $campaignRequestRepository->shouldReceive('save')->once()->with(\Mockery::type(CampaignRequest::class)); $useCase = new CreateCampaignRequest($campaignRequestRepository, $brandRepository); // WHEN $result = $useCase->execute($this->input); // THEN expect($result)->toBeInstanceOf(Output::class) ->and($result->status)->toBe(CampaignRequestStatus::CREATED) ->and($result->brandCode)->toBe($this->input->brandCode); }); }); describe('create campaign request use case validation rules', function (): void { it('throws when the brand does not exist', function (): void { // GIVEN $brandRepository = \Mockery::mock(BrandRepository::class); $brandRepository->shouldReceive('existsByCode')->once()->with($this->input->brandCode)->andReturn(false); $campaignRequestRepository = \Mockery::mock(CampaignRequestRepository::class); $campaignRequestRepository->shouldNotReceive('save'); $useCase = new CreateCampaignRequest($campaignRequestRepository, $brandRepository); // WHEN $action = fn (): Output => $useCase->execute($this->input); // THEN expect($action)->toThrow(BrandNotFoundException::class); }); });