From e6e9b5adbeb0ea0d676660a6de1ec7d5b51eff40 Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Mon, 20 Feb 2012 22:36:19 +0100 Subject: [PATCH] [Routing] Return the _route parameter from ApacheUrlMatcher --- .../Routing/Matcher/ApacheUrlMatcher.php | 1 + .../Routing/Matcher/ApacheUrlMatcherTest.php | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 tests/Symfony/Tests/Component/Routing/Matcher/ApacheUrlMatcherTest.php diff --git a/src/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php b/src/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php index 66ba4939d8d9..6e5e2db9c761 100644 --- a/src/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php @@ -52,6 +52,7 @@ public function match($pathinfo) if ('_route' == $name) { $match = true; + $parameters[$name] = $value; } elseif (0 === strpos($name, '_allow_')) { $allow[] = substr($name, 7); } else { diff --git a/tests/Symfony/Tests/Component/Routing/Matcher/ApacheUrlMatcherTest.php b/tests/Symfony/Tests/Component/Routing/Matcher/ApacheUrlMatcherTest.php new file mode 100644 index 000000000000..81963f04253f --- /dev/null +++ b/tests/Symfony/Tests/Component/Routing/Matcher/ApacheUrlMatcherTest.php @@ -0,0 +1,60 @@ +match($pathinfo, $server); + $this->assertSame(var_export($expect, true), var_export($result, true)); + } + + public function getMatchData() + { + return array( + array( + 'Simple route', + '/hello/world', + array( + '_ROUTING__route' => 'hello', + '_ROUTING__controller' => 'AcmeBundle:Default:index', + '_ROUTING_name' => 'world', + ), + array( + '_route' => 'hello', + '_controller' => 'AcmeBundle:Default:index', + 'name' => 'world', + ), + ), + array( + 'REDIRECT_ envs', + '/hello/world', + array( + 'REDIRECT__ROUTING__route' => 'hello', + 'REDIRECT__ROUTING__controller' => 'AcmeBundle:Default:index', + 'REDIRECT__ROUTING_name' => 'world', + ), + array( + '_route' => 'hello', + '_controller' => 'AcmeBundle:Default:index', + 'name' => 'world', + ), + ), + ); + } +} +