From 16dd0e5dda25edd50e2a1a83ac70c03fb8fee673 Mon Sep 17 00:00:00 2001 From: Tugdual Saunier Date: Wed, 30 Apr 2014 09:45:11 +0200 Subject: [PATCH] [WebProfilerBundle] added test case for #10773 --- .../Controller/ProfilerControllerTest.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php index de8a952fe9..bff1919aa9 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php @@ -13,6 +13,7 @@ namespace Symfony\Bundle\WebProfilerBundle\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Bundle\WebProfilerBundle\Controller\ProfilerController; +use Symfony\Component\HttpKernel\Profiler\Profile; use Symfony\Component\HttpFoundation\Request; class ProfilerControllerTest extends TestCase @@ -43,4 +44,34 @@ class ProfilerControllerTest extends TestCase array('empty'), ); } + + public function testReturns404onTokenNotFound() + { + $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()); + + $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()); + } }