/** * Tests the render() method. * * The given controller exists and there is also a route for the controller. Thus, the render() method of the * RouteRenderer should be called. * * @test * * @covers Cocur\Bundle\BuildBundle\Renderer\ControllerRenderer::render() * @covers Cocur\Bundle\BuildBundle\Renderer\ControllerRenderer::getControllerName() * @covers Cocur\Bundle\BuildBundle\Renderer\ControllerRenderer::getRoute() */ public function renderShouldRenderController() { $this->nameParser->shouldReceive('parse')->once()->andReturn('Acme\\DemoBundle\\Controller\\DefaultController::indexAction'); $route = m::mock('Symfony\\Component\\Routing\\Route'); $route->shouldReceive('getDefault')->with('_controller')->once()->andReturn('Acme\\DemoBundle\\Controller\\DefaultController::indexAction'); $routeCollection = m::mock('Symfony\\Component\\Routing\\RouteCollection'); $routeCollection->shouldReceive('all')->andReturn(['route1' => $route]); $this->router->shouldReceive('getRouteCollection')->once()->andReturn($routeCollection); $this->routeRenderer->shouldReceive('render')->with($route, 'route1')->once(); $this->renderer->render('AcmeDemoBundle:Default:index'); }
/** * Tests the render() method. * * Route collection returns two routes, one public and one private (prefixed with "_"), renderer * should only render the public route. * * @test * * @covers Cocur\Bundle\BuildBundle\Renderer\RoutesRenderer::render() * @covers Cocur\Bundle\BuildBundle\Renderer\RoutesRenderer::getRoutes() */ public function renderShouldRenderRoutesThatArePassedToTheConstructor() { $route = m::mock('Symfony\\Component\\Routing\\Route'); $routeCollection = m::mock('Symfony\\Component\\Routing\\RouteCollection'); $routeCollection->shouldReceive('get')->with('route1')->once()->andReturn($route); $this->router->shouldReceive('getRouteCollection')->once()->andReturn($routeCollection); $this->routeRenderer->shouldReceive('render')->with($route, 'route1')->once(); $renderer = new RoutesRenderer($this->routeRenderer, $this->router, ['route1']); $result = $renderer->render(); $this->assertEquals(1, $result); }