Add extensive controller and model tests
This commit is contained in:
33
tests/Unit/AttachmentGroupModelTest.php
Normal file
33
tests/Unit/AttachmentGroupModelTest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use App\Models\AttachmentExtension;
|
||||
use App\Models\AttachmentGroup;
|
||||
|
||||
it('exposes attachment group hierarchy and extensions', function (): void {
|
||||
$parent = AttachmentGroup::create([
|
||||
'name' => 'Parent',
|
||||
'max_size_kb' => 100,
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$child = AttachmentGroup::create([
|
||||
'name' => 'Child',
|
||||
'parent_id' => $parent->id,
|
||||
'position' => 1,
|
||||
'max_size_kb' => 100,
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$extension = AttachmentExtension::create([
|
||||
'extension' => 'png',
|
||||
'attachment_group_id' => $parent->id,
|
||||
'allowed_mimes' => ['image/png'],
|
||||
]);
|
||||
|
||||
$parent->load(['children', 'extensions']);
|
||||
$child->load('parent');
|
||||
|
||||
expect($parent->children->first()->id)->toBe($child->id);
|
||||
expect($parent->extensions->first()->id)->toBe($extension->id);
|
||||
expect($child->parent?->id)->toBe($parent->id);
|
||||
});
|
||||
Reference in New Issue
Block a user