fix: 🐛 change reject test for testing reason null
This commit is contained in:
parent
29c6428aaf
commit
69faddcd08
1 changed files with 11 additions and 21 deletions
|
|
@ -33,7 +33,6 @@ use Domain\Models\ValueObjects\ProcessingCode;
|
|||
use Domain\Models\ValueObjects\RequestedCoupon\RequestedCouponQuantity;
|
||||
use Domain\Models\ValueObjects\WarningThresholdQuantity;
|
||||
use Domain\Ports\Repositories\CampaignRequestRepository;
|
||||
use Shared\DDD\UseCases\Input as BaseInput;
|
||||
use Shared\Enums\Currency;
|
||||
use DateTime;
|
||||
use Domain\Models\ValueObjects\RequestedCoupon\RequestedCoupon;
|
||||
|
|
@ -81,7 +80,7 @@ describe('reject campaign request use case', function (): void {
|
|||
$repository = \Mockery::mock(CampaignRequestRepository::class);
|
||||
$repository->shouldReceive('findById')->once()->with($id)->andReturn($campaignRequest);
|
||||
$repository->shouldReceive('save')->once()->with(\Mockery::on(
|
||||
fn (CampaignRequest $saved): bool => $saved->status === CampaignRequestStatus::REJECTED
|
||||
fn(CampaignRequest $saved): bool => $saved->status === CampaignRequestStatus::REJECTED
|
||||
&& $saved->rejectionReason === $reason
|
||||
&& $saved->updatedAt !== null,
|
||||
));
|
||||
|
|
@ -137,35 +136,26 @@ describe('reject campaign request use case', function (): void {
|
|||
$useCase = new RejectCampaignRequest($repository);
|
||||
|
||||
// WHEN
|
||||
$action = fn (): Output => $useCase->execute(
|
||||
$action = fn(): Output => $useCase->execute(
|
||||
new Input(id: $id, reason: new RejectionReason('Missing legal documents.'))
|
||||
);
|
||||
|
||||
// THEN
|
||||
expect($action)->toThrow(\DomainException::class, 'Only a created campaign request can be rejected.');
|
||||
});
|
||||
});
|
||||
|
||||
describe('reject campaign request use case assertions', function (): void {
|
||||
it('cannot build an input to reject a campaign request without a reason', function (): void {
|
||||
it('never touches the repository when a rejection reason is missing', function (): void {
|
||||
// GIVEN
|
||||
$repository = \Mockery::mock(CampaignRequestRepository::class);
|
||||
$repository->shouldNotReceive('findById');
|
||||
$repository->shouldNotReceive('save');
|
||||
|
||||
$useCase = new RejectCampaignRequest($repository);
|
||||
|
||||
// WHEN
|
||||
$action = fn (): Input => new Input(id: CampaignRequestId::generate());
|
||||
$action = fn(): Output => $useCase->execute(new Input(id: CampaignRequestId::generate()));
|
||||
|
||||
// THEN
|
||||
expect($action)->toThrow(\ArgumentCountError::class);
|
||||
});
|
||||
it('rejects an input of the wrong type', function (): void {
|
||||
// GIVEN
|
||||
$repository = \Mockery::mock(CampaignRequestRepository::class);
|
||||
$useCase = new RejectCampaignRequest($repository);
|
||||
$invalidInput = new class () implements BaseInput
|
||||
{
|
||||
};
|
||||
|
||||
// WHEN
|
||||
$action = fn (): Output => $useCase->execute($invalidInput);
|
||||
|
||||
// THEN
|
||||
expect($action)->toThrow(\InvalidArgumentException::class);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue