Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Routing] fixed ApacheUrlMatcher and ApachMatcherDumper classes that …
…did not take care of default parameters in urls.
- Loading branch information
Hugo Hamon
committed
Jul 13, 2012
1 parent
3dc1fe0
commit e9d799c
Showing
5 changed files
with
123 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
tests/Symfony/Tests/Component/Routing/Matcher/ApacheUrlMatcherTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
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( | ||
'Route with params and defaults', | ||
'/hello/hugo', | ||
array( | ||
'_ROUTING__route' => 'hello', | ||
'_ROUTING__controller' => 'AcmeBundle:Default:index', | ||
'_ROUTING_name' => 'hugo', | ||
'_ROUTING_DEFAULTS_name' => 'world', | ||
), | ||
array( | ||
'name' => 'hugo', | ||
'_route' => 'hello', | ||
'_controller' => 'AcmeBundle:Default:index', | ||
), | ||
), | ||
array( | ||
'Route with defaults only', | ||
'/hello', | ||
array( | ||
'_ROUTING__route' => 'hello', | ||
'_ROUTING__controller' => 'AcmeBundle:Default:index', | ||
'_ROUTING_DEFAULTS_name' => 'world', | ||
), | ||
array( | ||
'name' => 'world', | ||
'_route' => 'hello', | ||
'_controller' => 'AcmeBundle:Default:index', | ||
), | ||
), | ||
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', | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters