|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Bundle\WebProfilerBundle\Tests\Controller; |
| 13 | + |
| 14 | +use Symfony\Bundle\FrameworkBundle\KernelBrowser; |
| 15 | +use Symfony\Bundle\FrameworkBundle\Routing\Router; |
| 16 | +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; |
| 17 | +use Symfony\Bundle\WebProfilerBundle\Tests\Functional\WebProfilerBundleKernel; |
| 18 | +use Symfony\Component\DomCrawler\Crawler; |
| 19 | +use Symfony\Component\Routing\Route; |
| 20 | + |
| 21 | +class RouterControllerTest extends WebTestCase |
| 22 | +{ |
| 23 | + public function testFalseNegativeTrace() |
| 24 | + { |
| 25 | + $path = '/foo/bar:123/baz'; |
| 26 | + |
| 27 | + $kernel = new WebProfilerBundleKernel(); |
| 28 | + $client = new KernelBrowser($kernel); |
| 29 | + $client->disableReboot(); |
| 30 | + $client->getKernel()->boot(); |
| 31 | + |
| 32 | + /** @var Router $router */ |
| 33 | + $router = $client->getContainer()->get('router'); |
| 34 | + $router->getRouteCollection()->add('route1', new Route($path)); |
| 35 | + |
| 36 | + $client->request('GET', $path); |
| 37 | + |
| 38 | + $crawler = $client->request('GET', '/_profiler/latest?panel=router&type=request'); |
| 39 | + |
| 40 | + $matchedRouteCell = $crawler |
| 41 | + ->filter('#router-logs .status-success td') |
| 42 | + ->reduce(function (Crawler $td) use ($path): bool { |
| 43 | + return $td->text() === $path; |
| 44 | + }); |
| 45 | + |
| 46 | + $this->assertSame(1, $matchedRouteCell->count()); |
| 47 | + } |
| 48 | +} |
0 commit comments