test nonexistant parent node id throws exception
This commit is contained in:
parent
021a2a6f15
commit
143a4ffe39
2 changed files with 20 additions and 4 deletions
|
|
@ -17,10 +17,10 @@ class CreateNode
|
|||
|
||||
public function execute(CreateNodeRequest $request): Node
|
||||
{
|
||||
$id = $request->textId;
|
||||
$text = $this->textRepo->find($id);
|
||||
$textId = $request->textId;
|
||||
$text = $this->textRepo->find($textId);
|
||||
if ($text === null) {
|
||||
throw new DomainException("Text with id: $id doesnt exist");
|
||||
throw new DomainException("Text with id: $textId doesnt exist");
|
||||
}
|
||||
if ($request->parentNodeId === null) {
|
||||
return $this->nodeRepo->create(new CreateNodeDto(
|
||||
|
|
@ -29,7 +29,11 @@ class CreateNode
|
|||
parentNode: null,
|
||||
));
|
||||
}
|
||||
$parentNode = $this->nodeRepo->find($request->parentNodeId);
|
||||
$parentNodeId = $request->parentNodeId;
|
||||
$parentNode = $this->nodeRepo->find($parentNodeId);
|
||||
if ($parentNode === null) {
|
||||
throw new DomainException("Node with id: $parentNodeId doesnt exist");
|
||||
}
|
||||
|
||||
return $this->nodeRepo->create(new CreateNodeDto(
|
||||
text: $text,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue