title: How to test file upload in Laravel 5.2
body: <p>Im trying to test an upload API but it fails every time: </p>
  
  <p><strong>Test Code :</strong></p>
  
  <pre><code>$JSONResponse = $this-&gt;call('POST', '/upload', [], [], [
      'photo' =&gt; new UploadedFile(base_path('public/uploads/test') . '/34610974.jpg', '34610974.jpg')
  ]);
  
  $this-&gt;assertResponseOk();
  $this-&gt;seeJsonStructure(['name']);
  
  $response = json_decode($JSONResponse);
  $this-&gt;assertTrue(file_exists(base_path('public/uploads') . '/' . $response['name']));
  </code></pre>
  
  <blockquote>
    <p>file path is /public/uploads/test/34610974.jpg</p>
  </blockquote>
  
  <p><strong>Here is My Upload code in a controller :</strong></p>
  
  <pre><code>$this-&gt;validate($request, [
      'photo' =&gt; 'bail|required|image|max:1024'
  ]);
  
  $name = 'adummyname' . '.' . $request-&gt;file('photo')-&gt;getClientOriginalExtension();
  
  $request-&gt;file('photo')-&gt;move('/uploads', $name);
  
  return response()-&gt;json(['name' =&gt; $name]);
  </code></pre>
  
  <p>How should I test file upload in <strong>Laravel 5.2</strong>? How to use <code>call</code> method to upload a file?</p>