Merge branch '2.3' into 2.7
* 2.3: Fix merge Fix missing _route parameter notice in RouterListener logging case Conflicts: src/Symfony/Component/HttpKernel/EventListener/RouterListener.php
This commit is contained in:
commit
bf8a923199
@ -140,7 +140,7 @@ class RouterListener implements EventSubscriberInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $this->logger) {
|
if (null !== $this->logger) {
|
||||||
$this->logger->info(sprintf('Matched route "%s".', $parameters['_route']), array(
|
$this->logger->info(sprintf('Matched route "%s".', isset($parameters['_route']) ? $parameters['_route'] : 'n/a'), array(
|
||||||
'route_parameters' => $parameters,
|
'route_parameters' => $parameters,
|
||||||
'request_uri' => $request->getUri(),
|
'request_uri' => $request->getUri(),
|
||||||
));
|
));
|
||||||
|
@ -128,4 +128,34 @@ class RouterListenerTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->assertEquals('GET', $context->getMethod());
|
$this->assertEquals('GET', $context->getMethod());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider getLoggingParameterData
|
||||||
|
*/
|
||||||
|
public function testLoggingParameter($parameter, $log)
|
||||||
|
{
|
||||||
|
$requestMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface');
|
||||||
|
$requestMatcher->expects($this->once())
|
||||||
|
->method('matchRequest')
|
||||||
|
->will($this->returnValue($parameter));
|
||||||
|
|
||||||
|
$logger = $this->getMock('Psr\Log\LoggerInterface');
|
||||||
|
$logger->expects($this->once())
|
||||||
|
->method('info')
|
||||||
|
->with($this->equalTo($log));
|
||||||
|
|
||||||
|
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
||||||
|
$request = Request::create('http://localhost/');
|
||||||
|
|
||||||
|
$listener = new RouterListener($requestMatcher, new RequestContext(), $logger, $this->requestStack);
|
||||||
|
$listener->onKernelRequest(new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLoggingParameterData()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array(array('_route' => 'foo'), 'Matched route "foo".'),
|
||||||
|
array(array(), 'Matched route "n/a".'),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user