public function testSubmitPostOrPutRequest($method)
{
$path = tempnam(sys_get_temp_dir(), 'sf2');
touch($path);
$values = array(
'author' => array(
'name' => 'Bernhard',
'image' => array('filename' => 'foobar.png'),
),
);
$files = array(
'author' => array(
'error' => array('image' => UPLOAD_ERR_OK),
'name' => array('image' => 'upload.png'),
'size' => array('image' => 123),
'tmp_name' => array('image' => $path),
'type' => array('image' => 'image/png'),
),
);
$request = new Request(array(), $values, array(), array(), $files, array(
'REQUEST_METHOD' => $method,
));
$form = $this->getBuilder('author')
->setMethod($method)
->setCompound(true)
->setDataMapper($this->getDataMapper())
->setRequestHandler(new HttpFoundationRequestHandler())
->getForm();
$form->add($this->getBuilder('name')->getForm());
$form->add($this->getBuilder('image')->getForm());
$form->handleRequest($request);
$file = new UploadedFile($path, 'upload.png', 'image/png', 123, UPLOAD_ERR_OK);
$this->assertEquals('Bernhard', $form['name']->getData());
$this->assertEquals($file, $form['image']->getData());
unlink($path);
}