В документации Symfony2 приведен простой пример:
$client->request('POST', '/submit', array('name' => 'Fabien'), array('photo' => '/path/to/photo'));
Чтобы имитировать загрузку файла.
Однако во всех моих тестах я ничего не получаю в объекте $request в приложении и ничего в массиве $_FILES.
Вот простой WebTestCase, который терпит неудачу. Он является самодостаточным и проверяет запрос, который строит клиент $на основе параметров, которые вы передаете. Он не тестирует приложение.
class UploadTest extends WebTestCase
{
public function testNewPhotos()
{
$client = $this->createClient();
$client->request(
'POST',
'/submit',
array('name' => 'Fabien'),
array('photo' => __FILE__)
);
$this->assertEquals(1, count($client->getRequest()->files->all()));
}
}
Просто чтобы быть ясным. Это не вопрос о том, как делать загрузки файлов, что я могу сделать. Речь идет о том, как протестировать их в Symfony2.
Edit
Я убежден, что делаю все правильно. Поэтому я создал тест для Framework и сделал запрос на pull. https://github.com/symfony/symfony/pull/1891