Closed
Description
I migrated all validation rules to your new system, which I like a lot. However, my old tests won't pass, because I'm told, the required fields haven't been filled out – but they are.
Here's a small example:
AddressForm (I have two more fields and a submit button in this class, but have cut them for this example):
$this
->add('address_1', 'text', [
'required' => true,
'label' => trans('label.address_1'),
'rules' => 'required|max:255',
]
)
->add('address_2', 'text', [
'required' => false,
'label' => trans('label.address_2'),
'rules' => 'max:255',
]
)
->add('city', 'text', [
'required' => true,
'label' => trans('label.city'),
'rules' => 'required|max:255',
]
)
->add('zip_code', 'text', [
'required' => true,
'label' => trans('label.zip_code'),
'rules' => 'required'
]
);
AddressController → update:
if (!$validation->isValid()) {
print_r($request->all());
print_r($validation->getErrors());
die();
return $this->redirectWithErrors($validation);
}
[...]
Test:
$address = factory(App\Address::class)->make()->toArray();
$address['address_1'] = 'User 1 Address 1 - Updated';
$this
->actingAs(User::find(3))
->visit('/address/1/edit')
->see(trans('address.edit.title'))
->see('User 1 Address 1')
->submitForm(trans('label.submit'), $address) // Here's the problem
->see(trans('address.edit.success'))
->see('User 1 Address 1 - Updated')
;
Test output:
Array
(
[_method] => PUT
[_token] => qxad1oeCsKvILU5vFzGNgJ5JkNC6hMh93MtiJ1BV
[address_1] => User 1 Address 1 - Updated
[address_2] => Apt. 602
[city] => Marienberg
[zip_code] => 82756
[country_id] => 276
)
Array
(
[address_1] => Array
(
[0] => The Address Field 1 field is required.
)
[city] => Array
(
[0] => The City field is required.
)
[zip_code] => Array
(
[0] => The ZIP code field is required.
)
[country_id] => Array
(
[0] => The Country field is required.
)
)
You can see that the data exists. Also, if I test in the browser, everything works fine. While debugging, I found out, that $this->getRequest()->all()
is empty (Form.php, Line 922). Do you guys have any clue, what it could be?
Thanks you guys for this amazing package!
Metadata
Metadata
Assignees
Labels
No labels