Skip to content

Commit

Permalink
Fix handling ESI request
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed May 16, 2019
1 parent 02a05a0 commit c92cfe6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/EventListener/RequestListener.php
Expand Up @@ -88,6 +88,10 @@ public function onKernelController(FilterControllerEvent $event): void
return;
}

if (! $event->getRequest()->attributes->has('_route')) {
return;
}

$matchedRoute = $event->getRequest()->attributes->get('_route');

Hub::getCurrent()
Expand Down
22 changes: 22 additions & 0 deletions test/EventListener/RequestListenerTest.php
Expand Up @@ -355,6 +355,28 @@ public function testOnKernelControllerAddsRouteTag(): void
$this->assertSame(['route' => 'sf-route'], $this->currentScope->getTags());
}

public function testOnKernelControllerRouteTagIsNotSetIfRequestDoesNotHaveARoute(): void
{
$this->currentHub->configureScope(Argument::type('callable'))
->shouldNotBeCalled();

$request = new Request();
$event = $this->prophesize(FilterControllerEvent::class);

$event->isMasterRequest()
->willReturn(true);
$event->getRequest()
->willReturn($request);

$listener = new RequestListener(
$this->currentHub->reveal(),
$this->prophesize(TokenStorageInterface::class)->reveal(),
$this->prophesize(AuthorizationCheckerInterface::class)->reveal()
);

$listener->onKernelController($event->reveal());
}

public function testOnKernelRequestUserDataAndTagsAreNotSetInSubRequest(): void
{
$this->currentHub->configureScope(Argument::type('callable'))
Expand Down

0 comments on commit c92cfe6

Please sign in to comment.