F
Filament6mo ago
Hager

i have this problem that the data didn't store in database and i get the table is empty when asserti

public function test_can_create_new_company()
{

$newData = Company::factory()->make();
$newData = $newData->toArray();

livewire(CompanyResource\Pages\CreateCompany::class)
->fillForm([
'name' => [
'ar' => $newData['name']['ar'],
'en' => $newData['name']['en'],
],
'description' => [
'ar' => $newData['description']['ar'],
'en' => $newData['description']['en'],
],
])
->call('create')
->assertHasNoFormErrors();

$this->assertDatabaseHas(Company::class, [
'name' => [
'ar' => $newData['name']['ar'],
'en' => $newData['name']['en'],
],
'description' => [
'ar' => $newData['description']['ar'],
'en' => $newData['description']['en'],
],

]);
}
public function test_can_create_new_company()
{

$newData = Company::factory()->make();
$newData = $newData->toArray();

livewire(CompanyResource\Pages\CreateCompany::class)
->fillForm([
'name' => [
'ar' => $newData['name']['ar'],
'en' => $newData['name']['en'],
],
'description' => [
'ar' => $newData['description']['ar'],
'en' => $newData['description']['en'],
],
])
->call('create')
->assertHasNoFormErrors();

$this->assertDatabaseHas(Company::class, [
'name' => [
'ar' => $newData['name']['ar'],
'en' => $newData['name']['en'],
],
'description' => [
'ar' => $newData['description']['ar'],
'en' => $newData['description']['en'],
],

]);
}
1 Reply
toeknee
toeknee6mo ago
are you using fillable on the model?
Want results from more Discord servers?
Add your server