title: Zend Framework 2 (ZF2) - PHPUnit and $this->url()->toRoute() does not work
body: <p>I was reading about ZF 2 (http://framework.zend.com/manual/2.0/en/user-guide/routing-and-controllers.html) and I have written a controller Test, but I already have a codified Action in my controller and, if not entered an ID, it directs the user to the indexAction, performing the test with PHPUnit works depending on how I do the redirect example:</p>
  
  <pre><code>// Does not Work
  return $ this-&gt; redirect () -&gt; toRoute ('my_route', array ('action' =&gt; 'index'));
  </code></pre>
  
  <p>Returns the following error message:</p>
  
  <blockquote>
    <p>TopAcl\Controller\MY_CONTROLLER_ControllerTest :: testEditarActionCanBeAcessed Zend\Mvc\Router\Exception\RuntimeException: Route with name "my_route" not found</p>
  </blockquote>
  
  <pre><code>// Works correctly
  return $ this-&gt; redirect () -&gt; toUrl ('/ resource');
  </code></pre>
  
  <p>I found nothing on the internet about it, is there any explanation? I need some more load file?</p>
  
  <pre><code>// Follow the setUp of my ControllerTest:
  protected function setUp ()
  {
      $ bootstrap = \Zend\Mvc\Application :: init (include 'config/application.config.php');
      $ this-&gt; controller = new ResourceController ();
      $ this-&gt; request = new Request ();
      $ this-&gt; routeMatch = new RouteMatch (array ('controller' =&gt; 'index'));
      $ this-&gt; event = $ bootstrap-&gt; getMvcEvent ();
      $ this-&gt; event-&gt; setRouteMatch ($ this-&gt; routeMatch);
      $ this-&gt; controller-&gt; SetEvent ($ this-&gt; event);
      $ this-&gt; controller-&gt; setEventManager ($ bootstrap-&gt; getEventManager ());
      $ this-&gt; controller-&gt; setServiceLocator ($ bootstrap-&gt; getServiceManager ());
  }
  </code></pre>