title: Functional test of a symfony2 controller: How to generate a route
body: <p>On a symfony2 controller, I would like to test a controller, which return a <code>Response</code> object. My test class extends from <code>WebTestCase</code>. I use the <code>static::createClient()</code> to get an operational client.</p>
  
  <p>My problem is <strong>to call the good route</strong> on my current installation with a virtual host.</p>
  
  <p><code>$client-&gt;getContainer()-&gt;get('router')-&gt;generate('my_route', array(), true)</code> generate a route with localhost as host. But that doesn't work as I have myproject.local as host.</p>
  
  <p><code>$client-&gt;getContainer()-&gt;get('kernel')-&gt;getRootDir()</code> and other dir method provide linux file path, not web path.</p>
  
  <p>I cannot hard code it as I am not alone on the project. So what is the method to get the correct route, or is there another way to test the controller?</p>