test that error is thrown if plan doesnt exist for creating scheduled node
This commit is contained in:
parent
449df516ae
commit
2affd2a84e
2 changed files with 20 additions and 1 deletions
|
|
@ -6,6 +6,7 @@ use App\Plan\PlanRepository;
|
|||
use App\ScheduledNode\ScheduledNode;
|
||||
use App\ScheduledNode\CreateScheduledNodeDto;
|
||||
use App\ScheduledNode\ScheduledNodeRepository;
|
||||
use DomainException;
|
||||
|
||||
class CreateScheduledNode
|
||||
{
|
||||
|
|
@ -17,7 +18,12 @@ class CreateScheduledNode
|
|||
public function execute(
|
||||
CreateScheduledNodeRequest $request
|
||||
): ScheduledNode {
|
||||
$plan = $this->planRepo->find($request->planId);
|
||||
$id = $request->planId;
|
||||
$plan = $this->planRepo->find($id);
|
||||
if ($plan === null) {
|
||||
throw new DomainException("Plan with id: $id doesnt exist");
|
||||
}
|
||||
|
||||
return $this->scheduledNodeRepo->create(
|
||||
new CreateScheduledNodeDto(
|
||||
date: $request->date,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue