test create node use case validates null fields
This commit is contained in:
parent
1f76fc08b6
commit
a429b647cc
1 changed files with 25 additions and 0 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Tests\Unit\Node\UseCases;
|
||||
|
||||
use App\Exceptions\BadRequestException;
|
||||
use App\Node\Node;
|
||||
use App\Node\NodeRepository;
|
||||
use App\Node\UseCases\CreateNode;
|
||||
|
|
@ -111,4 +112,28 @@ class CreateNodeTest extends TestCase
|
|||
parentNodeId: null,
|
||||
));
|
||||
}
|
||||
|
||||
public function test_throws_if_text_id_is_null(): void
|
||||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
$this->expectExceptionMessage('textId is required');
|
||||
|
||||
$this->useCase->execute(new CreateNodeRequest(
|
||||
textId: null,
|
||||
title: 'test',
|
||||
parentNodeId: null,
|
||||
));
|
||||
}
|
||||
|
||||
public function test_throws_if_title_is_null(): void
|
||||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
$this->expectExceptionMessage('title is required');
|
||||
|
||||
$this->useCase->execute(new CreateNodeRequest(
|
||||
textId: 0,
|
||||
title: null,
|
||||
parentNodeId: null,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue