/**
  * Tests the generate method with passing in a route object into generate().
  *
  * @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
  */
 public function testGenerateByRoute()
 {
     $this->generator = new ProviderBasedGenerator($this->provider);
     // Setup a route with a numeric parameter, but pass in a string, so it
     // fails and getRouteDebugMessage should be triggered.
     $route = new Route('/test');
     $route->setPath('/test/{number}');
     $route->setRequirement('number', '\\+d');
     $this->generator->setStrictRequirements(true);
     $context = new RequestContext();
     $this->generator->setContext($context);
     $this->assertSame(null, $this->generator->generate($route, array('number' => 'string')));
 }
 /**
  * {@inheritDoc}
  *
  * @param string $name       ignored.
  * @param array  $parameters must either contain the field 'route' with a
  *                           RouteObjectInterface or the field 'content_id'
  *                           with the id of a document implementing
  *                           RouteReferrersReadInterface.
  *
  * @throws RouteNotFoundException If there is no such route in the database
  */
 public function generate($name, $parameters = array(), $absolute = false)
 {
     if ($name instanceof SymfonyRoute) {
         $route = $this->getBestLocaleRoute($name, $parameters);
     } elseif (is_string($name) && $name) {
         $route = $this->getRouteByName($name, $parameters);
     } else {
         $route = $this->getRouteByContent($name, $parameters);
     }
     if (!$route instanceof SymfonyRoute) {
         $hint = is_object($route) ? get_class($route) : gettype($route);
         throw new RouteNotFoundException('Route of this document is not an instance of Symfony\\Component\\Routing\\Route but: ' . $hint);
     }
     $this->unsetLocaleIfNotNeeded($route, $parameters);
     return parent::generate($route, $parameters, $absolute);
 }