title: Can I use Laravel's `call` method to send raw JSON data in a unit test?
body: <p>I am attempting to unit test my implementation of a Stripe webhook handler. Stripe webhook data comes across the wire as raw JSON in the body of a POST request, so I capture and decode the data as such:</p>
  
  <pre><code>public function store()
  {
      $input = @file_get_contents("php://input");
      $request = json_decode($input);
      return Json::encode($request);
  }
  </code></pre>
  
  <p>I'm attempting to unit test this code, but I can't figure out how to send raw JSON data in a unit test such that I can retrieve it with the <code>file_get_contents("php:input//")</code> function. This is what I've tried (using <code>PHPUnit</code>):</p>
  
  <pre><code>protected $testRoute = 'api/stripe/webhook';
  
  protected $validWebhookJson = &lt;&lt;&lt;EOT
  {
    "id": "ch_14qE2r49NugaZ1RWEgerzmUI",
    "object": "charge",
    // and a bunch of other fields too
  }
  EOT;
  
  public function testWebhookDecdoesJsonIntoObject()
  {
      $response = $this-&gt;call('POST', $this-&gt;testRoute, $this-&gt;validWebhookJson); // fails because `$parameters` must be an array
      $response = $this-&gt;call('POST', $this-&gt;testRoute, [], [], ['CONTENT_TYPE' =&gt; 'application/json'], $this-&gt;validWebhookJson);
      dd($response-&gt;getData(true)); // array(0) {} BOOOO!!! Where for to my data go?
  }
  </code></pre>
  
  <p>I've also tried <code>curl</code> but that would make an external request, which doesn't make sense to me from a unit-testing perspective. How can I simulate a POST request with raw JSON data in the body that will be picked up by my <code>store</code> method?</p>