8000 Improve error reporting in router panel of web profiler by javiereguiluz · Pull Request #17744 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Improve error reporting in router panel of web profiler #17744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated tests
  • Loading branch information
javiereguiluz committed Feb 29, 2016
commit 0969aee3117bcfc146b888df9d2b9e55d487f870
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private function getTraces(RequestDataCollector $request, $method)
$request->getRequestServer()->get('REQUEST_METHOD'),
$request->getRequestAttributes()->all(),
$request->getRequestCookies()->all(),
[],
array(),
$request->getRequestServer()->all()
);

Expand Down
9CF1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\Routing\Tests\Matcher;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RequestContext;
Expand Down Expand Up @@ -99,18 +100,22 @@ public function getLevels($traces)
return $levels;
}

public function testExceptionOnRouteCondition()
public function testRoutesWithConditions()
{
$coll = new RouteCollection();
$coll->add('foo', new Route('/foo', array(), array(), array(), 'baz', array(), array(), "request.headers.get('User-Agent') matches '/firefox/i'"));
$routes = new RouteCollection();
$routes->add('foo', new Route('/foo', array(), array(), array(), 'baz', array(), array(), "request.headers.get('User-Agent') matches '/firefox/i'"));

$context = new RequestContext();
$context->setHost('baz');

$matcher = new TraceableUrlMatcher($coll, $context);
$traces = $matcher->getTraces('/foo');
$matcher = new TraceableUrlMatcher($routes, $context);

$notMatchingRequest = Request::create('/foo', 'GET');
$traces = $matcher->getTracesFromRequest($notMatchingRequest);
$this->assertEquals("Condition \"request.headers.get('User-Agent') matches '/firefox/i'\" does not evaluate to \"true\"", $traces[0]['log']);

$this->assertEquals(-1, $traces[0]['level']);
$this->assertRegExp('/\[ERROR\] The following exception prevented the route to be matched against application routes: "Unable to get a property on a non-object\." \(in .* line \d+\)/', $traces[0]['log']);
$matchingRequest = Request::create('/foo', 'GET', array(), array(), array(), array('HTTP_USER_AGENT' => 'Firefox'));
$traces = $matcher->getTracesFromRequest($matchingRequest);
$this->assertEquals("Route matches!", $traces[0]['log']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fabbot suggest to use single quote here.

}
}
0