symfony WebTestCase client does not send post data
<p>I'm currently writing functionnal tests for my symfony app. I use symfony 3 (3.1.6) with phpunit 5.6.1.
<strong>Edit</strong> : As requested by Alvin Bunk, my app is not a website, it is an API that returns only JSON. As i added in the two updates below, the Symfony test client sends a proper request object with the form data but the controller of the app receives an empty object.</p>

<p>Here is the code i use to test my form : </p>

<pre><code>public function testSaveMediaFromMediaUrl()
{
    $client = static::createClient();
    $crawler = $client-&gt;request('GET', '/form');

    $form = $crawler-&gt;selectButton('OK')-&gt;form();
    $form['mediaUrl'] = 'http://example.com';

    $client-&gt;submit($form);
    var_dump($client-&gt;getResponse()-&gt;getContent());
}
</code></pre>

<p>The correct action of my controller is called but there is nothing in the request object when the action is called from the tests suite. using a regular web browser, everything works fine. In the controller, I use <code>$request = Request::createFromGlobals();</code> to create the request object</p>

<p>I also tried this code to post the data and I get the same result : no POST data is received in the controller.</p>

<p>direct post request without using the form</p>

<pre><code>public function testSaveMediaFromMediaUrl()
{
    $client = static::createClient();
    $crawler = $client-&gt;request('POST', '/media', ['mediaUrl' =&gt; 'http://example.com']);

    var_dump($crawler-&gt;html());
}
</code></pre>

<p>adding the data in the submit method</p>

<pre><code>public function testSaveMediaFromMediaUrl()
{
    $client = static::createClient();
    $crawler = $client-&gt;request('GET', '/form');

    $form = $crawler-&gt;selectButton('OK')-&gt;form();

    $client-&gt;submit($form, ['mediaUrl' =&gt; 'http://example.com']);
    var_dump($client-&gt;getResponse()-&gt;getContent());
}
</code></pre>

<p>Is there something I'm doing wrong ?</p>

<h2>EDIT:</h2>

<p>Here is the dump of the request object I get in the controller action.</p>

<pre><code>.object(Symfony\Component\HttpFoundation\Request)#1047 (21) {
  ["attributes"]=&gt;
  object(Symfony\Component\HttpFoundation\ParameterBag)#1050 (1) {
    ["parameters":protected]=&gt;
    array(0) {
    }
  }
  ["request"]=&gt;
  object(Symfony\Component\HttpFoundation\ParameterBag)#1048 (1) {
    ["parameters":protected]=&gt;
    array(0) {
    }
  }
  ["query"]=&gt;
  object(Symfony\Component\HttpFoundation\ParameterBag)#1049 (1) {
    ["parameters":protected]=&gt;
    array(0) {
    }
  }
  ["server"]=&gt;
  object(Symfony\Component\HttpFoundation\ServerBag)#1053 (1) {
    ["parameters":protected]=&gt;
    array(35) {[...]}
  }
  ["files"]=&gt;
  object(Symfony\Component\HttpFoundation\FileBag)#1052 (1) {
    ["parameters":protected]=&gt;
    array(0) {
    }
  }
  ["cookies"]=&gt;
  object(Symfony\Component\HttpFoundation\ParameterBag)#1051 (1) {
    ["parameters":protected]=&gt;
    array(0) {
    }
  }
  ["headers"]=&gt;
  object(Symfony\Component\HttpFoundation\HeaderBag)#1054 (2) {
    ["headers":protected]=&gt;
    array(0) {
    }
    ["cacheControl":protected]=&gt;
    array(0) {
    }
  }
  ["content":protected]=&gt;
  NULL
  ["languages":protected]=&gt;
  NULL
  ["charsets":protected]=&gt;
  NULL
  ["encodings":protected]=&gt;
  NULL
  ["acceptableContentTypes":protected]=&gt;
  NULL
  ["pathInfo":protected]=&gt;
  NULL
  ["requestUri":protected]=&gt;
  NULL
  ["baseUrl":protected]=&gt;
  NULL
  ["basePath":protected]=&gt;
  NULL
  ["method":protected]=&gt;
  NULL
  ["format":protected]=&gt;
  NULL
  ["session":protected]=&gt;
  NULL
  ["locale":protected]=&gt;
  NULL
  ["defaultLocale":protected]=&gt;
  string(2) "en"
}
</code></pre>

<h2>Edit-2:</h2>

<p>Here is the dump of the request object sent by the client (in the test case : <code>var_dump($client-&gt;getRequest()-&gt;request);</code>) :</p>

<pre><code>object(Symfony\Component\HttpFoundation\ParameterBag)#753 (1) {
  ["parameters":protected]=&gt;
  array(4) {
    ["mediaUrl"]=&gt;
    string(41) "http://example.com"
    ["url"]=&gt;
    string(0) ""
    ["token"]=&gt;
    string(0) ""
    ["sizes"]=&gt;
    string(0) ""
  }
}
</code></pre>

<p>The "test browser" seems sends the form data to the app...</p>