protected function makeRequestUsingForm(Form $form) { $files = []; $plainFiles = $form->getFiles(); foreach ($plainFiles as $key => $file) { $files[$key] = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error'], true); } return $this->makeRequest($form->getMethod(), $form->getUri(), $form->getValues(), [], $files); }
public function isValid(Form $form) { if ($form->has('token')) { $values = $form->getValues(); $values['token'] = 'modified by csrf scanner'; $form->setValues($values); $this->client->submit($form); $status = $this->client->getResponse()->getStatus(); if (403 == $status) { return true; } $this->message = "403 response expected, but got a {$status}"; } else { $this->message = "No 'token' input field found"; } return false; }
/** * Extract the parameters from the given form. * * @param \Symfony\Component\DomCrawler\Form $form * @return array */ protected function extractParametersFromForm(Form $form) { parse_str(http_build_query($form->getValues()), $parameters); return $parameters; }
/** * Make a request to a URL using form parameters. * * @param Form $form * @return static */ protected function makeRequestUsingForm(Form $form) { return $this->makeRequest($form->getMethod(), $form->getUri(), $form->getValues(), [], $form->getFiles()); }