Skip to content

Commit

Permalink
[Routing] Return the _route parameter from ApacheUrlMatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-lb committed Feb 23, 2012
1 parent 4a0057f commit e6e9b5a
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php
Expand Up @@ -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 {
Expand Down
@@ -0,0 +1,60 @@
<?php

namespace Symfony\Tests\Component\Routing\Matcher;

use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Matcher\ApacheUrlMatcher;

class ApacheUrlMatcherTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider getMatchData
*/
public function testMatch($name, $pathinfo, $server, $expect)
{
$collection = new RouteCollection;
$context = new RequestContext;
$matcher = new ApacheUrlMatcher($collection, $context);

$_SERVER = $server;

$result = $matcher->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',
),
),
);
}
}

0 comments on commit e6e9b5a

Please sign in to comment.