Author: Fabien Potencier (fabien@symfony.com)
Inheritance: extends Symfony\Component\DependencyInjection\ContainerAware
 /**
  * @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());
 }
 public function testSearchResult()
 {
     $urlGenerator = $this->getMock('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface');
     $twig = $this->getMock('Twig_Environment');
     $profiler = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Profiler\\Profiler')->disableOriginalConstructor()->getMock();
     $controller = new ProfilerController($urlGenerator, $profiler, $twig, array());
     $tokens = array(array('token' => 'token1', 'ip' => '127.0.0.1', 'method' => 'GET', 'url' => 'http://example.com/', 'time' => 0, 'parent' => null, 'status_code' => 200), array('token' => 'token2', 'ip' => '127.0.0.1', 'method' => 'GET', 'url' => 'http://example.com/not_found', 'time' => 0, 'parent' => null, 'status_code' => 404));
     $profiler->expects($this->once())->method('find')->will($this->returnValue($tokens));
     $twig->expects($this->once())->method('render')->with($this->stringEndsWith('results.html.twig'), $this->equalTo(array('token' => 'empty', 'profile' => null, 'tokens' => $tokens, 'ip' => '127.0.0.1', 'method' => 'GET', 'url' => 'http://example.com/', 'start' => null, 'end' => null, 'limit' => 2, 'panel' => null)));
     $response = $controller->searchResultsAction(Request::create('/_profiler/empty/search/results', 'GET', array('limit' => 2, 'ip' => '127.0.0.1', 'method' => 'GET', 'url' => 'http://example.com/')), 'empty');
     $this->assertEquals(200, $response->getStatusCode());
 }
 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);
         }
         return;
     }));
     $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());
 }