fabpot/Goutte — Issue #37: Problem with file upload
Author: stoefln
Created: 2012-01-25 17:18:14+00:00
State: open

I'm using Behat and Mink to test a file upload. The upload action looks like that:

public function importCsvAction()
{
$csvFile = new CSVFile($this->getUser());
$form = $this->createFormBuilder($csvFile)
->add('file')
->getForm();

if ($this->getRequest()->getMethod() === 'POST') {
$form->bindRequest($this->getRequest());

if ($form->isValid()) {
$csvFile->upload();
$this->persistAndFlush($csvFile);
return new RedirectResponse($this->generateUrl('_contact_importcsvmapping', array('hash' => $csvFile->getHash())));
}
}

return array('form' => $form->createView());
}

However, if I run the testing script, the form tells me "This value should not be empty". My script looks like that:

Scenario: Import from CSV
Given I am logged in as "promoter"
And I follow "Contacts"
And I follow "import email contacts"
And I attach the file "/Users/stephan/Downloads/email-export.csv" to "form[file]"
And I press "import"
Then show last response
And I press "import data now"
Then I should see "success"

Is this a bug in goutte? It seems like there is no file data sent in the request.