[WebProfilerBundle] added test case for #10773
This commit is contained in:
parent
5b91e70777
commit
16dd0e5dda
@ -13,6 +13,7 @@ namespace Symfony\Bundle\WebProfilerBundle\Tests\Controller;
|
|||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||||
use Symfony\Bundle\WebProfilerBundle\Controller\ProfilerController;
|
use Symfony\Bundle\WebProfilerBundle\Controller\ProfilerController;
|
||||||
|
use Symfony\Component\HttpKernel\Profiler\Profile;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
class ProfilerControllerTest extends TestCase
|
class ProfilerControllerTest extends TestCase
|
||||||
@ -43,4 +44,34 @@ class ProfilerControllerTest extends TestCase
|
|||||||
array('empty'),
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user