/**
  * Renders all public routes, that is, routes that do not start with "_".
  *
  * @return integer Number of rendered routes
  */
 public function render()
 {
     $counter = 0;
     foreach ($this->getRoutes() as $name => $route) {
         if ('_' !== substr($name, 0, 1)) {
             $this->routeRenderer->render($route, $name);
             $counter += 1;
         }
     }
     return $counter;
 }
 /**
  * Renders the page with the given controller name.
  *
  * @param string $controllerName Name of the controller
  */
 public function render($controllerName)
 {
     $controller = $this->getControllerName($controllerName);
     if (null === $controller) {
         throw new ControllerNotFoundException(sprintf('Could not find controller "%s".', $controllerName));
     }
     $route = $this->getRoute($controller);
     if (null === $route) {
         throw new RouteNotFoundException(sprintf('Could not find route for controller "%s".', $controllerName));
     }
     $this->routeRenderer->render($route[1], $route[0]);
 }
 /**
  * Tests the render() method.
  *
  * The render() method creates a request based on the given route and lets the kernel handle the request. The
  * response is saved to disk. A generator is used to generate multiple responses.
  *
  * @test
  *
  * @covers Cocur\Bundle\BuildBundle\Renderer\RouteRenderer::render()
  * @covers Cocur\Bundle\BuildBundle\Renderer\RouteRenderer::renderWithParameters()
  * @covers Cocur\Bundle\BuildBundle\Renderer\RouteRenderer::buildRequest()
  */
 public function renderShouldRenderRouteWithGenerator()
 {
     $generator = m::mock('Cocur\\Bundle\\BuildBundle\\Generator\\GeneratorInterface');
     $generator->shouldReceive('generate')->once()->andReturn([['var' => 'foo'], ['var' => 'bar']]);
     $this->generatorCollection->shouldReceive('has')->with('index')->once()->andReturn(true);
     $this->generatorCollection->shouldReceive('get')->with('index')->once()->andReturn($generator);
     $this->router->shouldReceive('generate')->with('index', ['var' => 'foo'])->twice()->andReturn('/index/foo.html');
     $this->router->shouldReceive('generate')->with('index', ['var' => 'bar'])->twice()->andReturn('/index/bar.html');
     $route = m::mock('Symfony\\Component\\Routing\\Route');
     $response = m::mock('Symfony\\Component\\HttpFoundation\\Response');
     $response->shouldReceive('getContent')->twice()->andReturn('Foobar!');
     $this->kernel->shouldReceive('handle')->with(m::any())->twice()->andReturn($response);
     $this->kernel->shouldReceive('terminate')->with(m::any(), $response)->twice();
     $this->kernel->shouldReceive('shutdown')->twice();
     $this->writer->shouldReceive('write')->with('/index/foo.html', 'Foobar!')->once();
     $this->writer->shouldReceive('write')->with('/index/bar.html', 'Foobar!')->once();
     $this->renderer->render($route, 'index');
 }