Commit 94ba4a23 authored by Korko's avatar Korko
Browse files

For tests purposes, allow also real numeric -1 in POST not only strings

parent 3e440132
......@@ -46,7 +46,7 @@ class RandomFormRequest extends Request
$rules += [
'email.'.$key => 'required_without:phone.'.$key.'|email',
'phone.'.$key => 'required_without:email.'.$key.'|numeric|regex:#0[67]\d{8}#',
'partner.'.$key => (isset($this->request->get('partner')[$key]) && $this->request->get('partner')[$key] !== '-1') ? 'sometimes|numeric|fieldinkeys:name,'.$key : 'sometimes|numeric',
'partner.'.$key => (isset($this->request->get('partner')[$key]) && $this->request->get('partner')[$key] != '-1') ? 'sometimes|numeric|fieldinkeys:name,'.$key : 'sometimes|numeric',
];
}
}
......
......@@ -82,6 +82,9 @@ class RequestTest extends TestCase
// Names and partners
public function testPartners()
{
$content = $this->ajaxPost('/', ['name' => ['toto', 'tata'], 'partner' => [87, -1]], 422);
$this->assertArrayKeysEquals(['g-recaptcha-response', 'partner.0', 'phone.0', 'phone.1', 'email.0', 'email.1'], $content);
$content = $this->ajaxPost('/', ['name' => ['toto', 'tata'], 'partner' => [87]], 422);
$this->assertArrayKeysEquals(['g-recaptcha-response', 'partner.0', 'phone.0', 'phone.1', 'email.0', 'email.1'], $content);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment