Skip to content

Commit

Permalink
Merge pull request #213 from franmomu/fix_esi_request
Browse files Browse the repository at this point in the history
Fix handling ESI request
  • Loading branch information
Jean85 committed May 16, 2019
2 parents dbdc4f1 + 5836618 commit 84cb150
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/EventListener/RequestListener.php
Expand Up @@ -88,7 +88,11 @@ public function onKernelController(FilterControllerEvent $event): void
return;
}

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

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

Hub::getCurrent()
->configureScope(function (Scope $scope) use ($matchedRoute): void {
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 84cb150

Please sign in to comment.