I have an HTML form which contains the following input: <input type="file" name="sentFile" /> The form has NOT been generated with $this->createFormBuilder(). I have written a class that extends WebTestCase. Its testing method does the following:
$crawler = $client->request('GET', '/users/import'); $buttonCrawlerNode = $crawler->selectButton('Import'); $form = $buttonCrawlerNode->form(); $testfile = 'import_users.csv'; $destination = 'F:/www/symfony/web/uploads/' . $testfile; $form['sentFile']->upload($destination); $form['myparam'] = 'hello'; $crawler = $client->submit($form); But when I run the test with the phpunit command, the controller method which receives the posted form shows an empty $_FILES. The other input (myparam) is correctly received. So how can use the uploaded file?
PS:
- I have not succeeded to use PHPT in Symfony (stackoverflow.com/questions/4922207/integrate-phpt-test-cases-with-phpunit/4925061).
- I have not tried Selenium yet
References:
'F:/www/symfony/web/uploads/'for the uplaod directory is a good practise?