test bulk create nodes validates null fields
This commit is contained in:
parent
6c1ecc8b38
commit
5de15ef52d
1 changed files with 53 additions and 0 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Tests\Unit\Node\UseCases;
|
namespace Tests\Unit\Node\UseCases;
|
||||||
|
|
||||||
|
use App\Exceptions\BadRequestException;
|
||||||
use App\Node\CreateNodeDto;
|
use App\Node\CreateNodeDto;
|
||||||
use App\Node\Node;
|
use App\Node\Node;
|
||||||
use App\Node\UseCases\BulkCreateNodes;
|
use App\Node\UseCases\BulkCreateNodes;
|
||||||
|
|
@ -131,4 +132,56 @@ class BulkCreateNodesTest extends TestCase
|
||||||
count: 5,
|
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,
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue