From 5de15ef52d8dbff961940c8b22403aaf8c05e6fd Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sun, 19 Apr 2026 23:09:40 +0300 Subject: [PATCH] test bulk create nodes validates null fields --- .../Node/UseCases/BulkCreateNodesTest.php | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tests/Unit/Node/UseCases/BulkCreateNodesTest.php b/tests/Unit/Node/UseCases/BulkCreateNodesTest.php index b3f6240..13072db 100644 --- a/tests/Unit/Node/UseCases/BulkCreateNodesTest.php +++ b/tests/Unit/Node/UseCases/BulkCreateNodesTest.php @@ -2,6 +2,7 @@ namespace Tests\Unit\Node\UseCases; +use App\Exceptions\BadRequestException; use App\Node\CreateNodeDto; use App\Node\Node; use App\Node\UseCases\BulkCreateNodes; @@ -131,4 +132,56 @@ class BulkCreateNodesTest extends TestCase count: 5, )); } + + public function test_throws_if_text_id_is_null(): void + { + $this->expectException(BadRequestException::class); + $this->expectExceptionMessage('textId is required'); + + $this->useCase->execute(new BulkCreateNodesRequest( + textId: null, + parentNodeId: $this->parentNode->getId(), + titlePrefix: 'Page', + count: 5, + )); + } + + public function test_throws_if_parent_node_id_is_null(): void + { + $this->expectException(BadRequestException::class); + $this->expectExceptionMessage('parentNodeId is required'); + + $this->useCase->execute(new BulkCreateNodesRequest( + textId: 0, + parentNodeId: null, + titlePrefix: 'Page', + count: 5, + )); + } + + public function test_throws_if_title_prefix_is_null(): void + { + $this->expectException(BadRequestException::class); + $this->expectExceptionMessage('titlePrefix is required'); + + $this->useCase->execute(new BulkCreateNodesRequest( + textId: 0, + parentNodeId: $this->parentNode->getId(), + titlePrefix: null, + count: 5, + )); + } + + public function test_throws_if_count_is_null(): void + { + $this->expectException(BadRequestException::class); + $this->expectExceptionMessage('count is required'); + + $this->useCase->execute(new BulkCreateNodesRequest( + textId: 0, + parentNodeId: $this->parentNode->getId(), + titlePrefix: 'Page', + count: null, + )); + } }