title: Laravel 5 unit testing. Unable to set JSON of Request object
body: <p>How on earth do you get Laravel 5.0 to accept a JSON encoded string into it's request object? Because my REST api is returning 500 errors, and upon closer inspection, the request object has an empty json property...?</p>
  
  <p>My array:</p>
  
  <pre><code>    private $test_1_create_user = array(
          "name" =&gt; "Mr T Est",
          "email" =&gt; "mrtest@somedomain.com",
          "password" =&gt; "testing1234"
      );
  </code></pre>
  
  <p>My test method:</p>
  
  <pre><code>    /**
      * Attempts to Create a single user with no permissions
      */
      public function testCreateUser(){
          /** Obtain instance of Request object */
          $req = $this-&gt;app-&gt;request-&gt;instance();
          /** Set the JSON packet */
          $req-&gt;json(json_encode($this-&gt;test_1_create_user));
          /** Run the test */
          $response = $this-&gt;call('POST', '/api/v1/user');
          /** Read the response */    
          $this-&gt;assertResponseOk();
      }
  </code></pre>
  
  <p>And a <code>var_dump</code> of $req (slimmed down a bit):</p>
  
  <pre><code>C:\wamp\www\nps&gt;php phpunit.phar
  PHPUnit 4.6.2 by Sebastian Bergmann and contributors.
  
  Configuration read from C:\wamp\www\nps\phpunit.xml
  
  class Illuminate\Http\Request#34 (25) {
    protected $json =&gt;
    class Symfony\Component\HttpFoundation\ParameterBag#261 (1) {
      protected $parameters =&gt;
      array(0) {
      }
    }
    protected $sessionStore =&gt;
    NULL
    protected $userResolver =&gt;
    NULL
    protected $routeResolver =&gt;
    NULL
    public $attributes =&gt;
    class Symfony\Component\HttpFoundation\ParameterBag#41 (1) {
      protected $parameters =&gt;
      array(0) {
      }
    }
    public $request =&gt;
    class Symfony\Component\HttpFoundation\ParameterBag#43 (1) {
      protected $parameters =&gt;
      array(0) {
     }
   }
  </code></pre>
  
  <p>It took me quite a while to figure out how to access the request object from within a unit test. Anyone have any ideas as to why the <code>$req->json</code> is always empty? :( Cheers!</p>