Skip to content

Commit dad12f2

Browse files
Add test for creating a record in CanCreateRecordTest
1 parent 5322591 commit dad12f2

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@php use Illuminate\Support\Facades\Log; @endphp
2+
it('can create a record', function (): void {
3+
$record = {{ $getResourceModel() }}::factory()->make();
4+
5+
livewire({{ $getPageClass('create') }}::class)
6+
->fillForm([
7+
@foreach($getResourceFormFields() as $key => $field)
8+
'{{ $key }}' => $record->{{ $key }},
9+
@endforeach
10+
])
11+
->call('create')
12+
->assertNotified();
13+
14+
$this->assertDatabaseHas({{ $getResourceModel() }}::class, [
15+
@foreach($getResourceFormFields() as $key => $field)
16+
'{{ $key }}' => $record->{{ $key }},
17+
@endforeach
18+
]);
19+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace CodeWithDennis\FilamentTests\TestRenderers\Resources\Pages\Create;
4+
5+
use CodeWithDennis\FilamentTests\TestRenderers\BaseTest;
6+
7+
class CanCreateRecordTest extends BaseTest
8+
{
9+
public ?string $view = 'filament-tests::resources.pages.create.can-create-record';
10+
11+
public function getShouldRender(): bool
12+
{
13+
return $this->hasPage('create');
14+
}
15+
}

0 commit comments

Comments
 (0)