Skip to content

Commit ca07fd6

Browse files
committed
Add rules test
1 parent 518d69e commit ca07fd6

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/Unit/HasOneTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Laravel\Nova\Fields\Text;
66
use Laravel\Nova\Http\Requests\NovaRequest;
77
use Illuminate\Foundation\Testing\WithFaker;
8+
use Illuminate\Validation\ValidationException;
89
use Illuminate\Foundation\Testing\RefreshDatabase;
910
use KirschbaumDevelopment\NovaInlineRelationship\Tests\Profile;
1011
use KirschbaumDevelopment\NovaInlineRelationship\Tests\Employee;
@@ -93,4 +94,21 @@ public function testFillAttributeForCreate()
9394
$this->assertEquals($profile->id, $id);
9495
});
9596
}
97+
98+
public function testRuleIsEnforced()
99+
{
100+
$request = [
101+
'name' => 'Test',
102+
'profile' => [
103+
[
104+
'phone' => null,
105+
],
106+
],
107+
];
108+
109+
$this->employeeResource->resolveFieldForAttribute(new NovaRequest(), 'profile');
110+
111+
$this->expectException(ValidationException::class);
112+
$this->employeeResource::validateForUpdate(new NovaRequest($request));
113+
}
96114
}

0 commit comments

Comments
 (0)