Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed information about how to simulate a file upload

  • Loading branch information...
commit e6027eb661509a4452da1de15198f6b8bc3ab2a3 1 parent 7d52ca9
@fabpot fabpot authored
Showing with 11 additions and 1 deletion.
  1. +11 −1 book/testing.rst
View
12 book/testing.rst
@@ -286,11 +286,21 @@ additional arguments of the ``request()`` method::
$client->request('POST', '/submit', array('name' => 'Fabien'));
// Form submission with a file upload
- $client->request('POST', '/submit', array('name' => 'Fabien'), array('photo' => '/path/to/photo'));
+ use Symfony\Component\HttpFoundation\File\UploadedFile;
+
+ $photo = new UploadedFile('/path/to/photo.jpg', 'photo.jpg', 'image/jpeg', 123);
+ // or
+ $photo = array('tmp_name' => '/path/to/photo.jpg', 'name' => 'photo.jpg', 'type' => 'image/jpeg', 'size' => 123, 'error' => UPLOAD_ERR_OK);
+
+ $client->request('POST', '/submit', array('name' => 'Fabien'), array('photo' => $photo));
// Specify HTTP headers
$client->request('DELETE', '/post/12', array(), array(), array('PHP_AUTH_USER' => 'username', 'PHP_AUTH_PW' => 'pa$$word'));
+.. tip::
+
+ Form submissions are greatly simplified by using a crawler object (see below).
+
When a request returns a redirect response, the client automatically follows
it. This behavior can be changed with the ``followRedirects()`` method::

0 comments on commit e6027eb

Please sign in to comment.
Something went wrong with that request. Please try again.