test create plan use case validates null fields
This commit is contained in:
parent
f77101e4e9
commit
86052efbcb
1 changed files with 37 additions and 0 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Tests\Unit\Plan\UseCases;
|
||||
|
||||
use App\Exceptions\BadRequestException;
|
||||
use App\Node\CreateNodeDto;
|
||||
use App\Plan\UseCases\CreatePlan;
|
||||
use App\Plan\UseCases\CreatePlanRequest;
|
||||
|
|
@ -125,4 +126,40 @@ class CreatePlanTest extends TestCase
|
|||
$this->scheduledNodeRepo->getNumberOfTimesCreateCalled()
|
||||
);
|
||||
}
|
||||
|
||||
public function test_throws_if_user_id_is_null(): void
|
||||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
$this->expectExceptionMessage('userId is required');
|
||||
|
||||
$this->useCase->execute(new CreatePlanRequest(
|
||||
userId: null,
|
||||
name: 'testPlan',
|
||||
textId: 0,
|
||||
));
|
||||
}
|
||||
|
||||
public function test_throws_if_text_id_is_null(): void
|
||||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
$this->expectExceptionMessage('textId is required');
|
||||
|
||||
$this->useCase->execute(new CreatePlanRequest(
|
||||
userId: 0,
|
||||
name: 'testPlan',
|
||||
textId: null,
|
||||
));
|
||||
}
|
||||
|
||||
public function test_throws_if_name_is_null(): void
|
||||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
$this->expectExceptionMessage('name is required');
|
||||
|
||||
$this->useCase->execute(new CreatePlanRequest(
|
||||
userId: 0,
|
||||
name: null,
|
||||
textId: 0,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue