toolbarAction() public method

Renders the Web Debug Toolbar.
public toolbarAction ( string $token, string $position = null ) : Response
$token string The profiler token
$position string The toolbar position (bottom, normal, or null -- automatically guessed)
return Symfony\Component\HttpFoundation\Response A Response instance
Ejemplo n.º 1
0
 public function testReturns404onTokenNotFound()
 {
     $urlGenerator = $this->getMock('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface');
     $twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
     $profiler = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Profiler\\Profiler')->disableOriginalConstructor()->getMock();
     $controller = new ProfilerController($urlGenerator, $profiler, $twig, array());
     $profiler->expects($this->exactly(2))->method('loadProfile')->will($this->returnCallback(function ($token) {
         if ('found' == $token) {
             return new Profile($token);
         }
     }));
     $response = $controller->toolbarAction(Request::create('/_wdt/found'), 'found');
     $this->assertEquals(200, $response->getStatusCode());
     $response = $controller->toolbarAction(Request::create('/_wdt/notFound'), 'notFound');
     $this->assertEquals(404, $response->getStatusCode());
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider getEmptyTokenCases
  */
 public function testEmptyToken($token)
 {
     $urlGenerator = $this->getMockBuilder('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface')->getMock();
     $twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
     $profiler = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Profiler\\Profiler')->disableOriginalConstructor()->getMock();
     $controller = new ProfilerController($urlGenerator, $profiler, $twig, array());
     $response = $controller->toolbarAction(Request::create('/_wdt/empty'), $token);
     $this->assertEquals(200, $response->getStatusCode());
 }