4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Routing\Tests\Matcher
;
14 use Symfony\Component\Routing\RouteCollection
;
15 use Symfony\Component\Routing\RequestContext
;
16 use Symfony\Component\Routing\Matcher\ApacheUrlMatcher
;
18 class ApacheUrlMatcherTest
extends \PHPUnit_Framework_TestCase
22 protected function setUp()
24 $this->server
= $_SERVER;
27 protected function tearDown()
29 $_SERVER = $this->server
;
33 * @dataProvider getMatchData
35 public function testMatch($name, $pathinfo, $server, $expect)
37 $collection = new RouteCollection();
38 $context = new RequestContext();
39 $matcher = new ApacheUrlMatcher($collection, $context);
43 $result = $matcher->match($pathinfo, $server);
44 $this->assertSame(var_export($expect, true), var_export($result, true));
47 public function getMatchData()
54 '_ROUTING_route' => 'hello',
55 '_ROUTING_param__controller' => 'AcmeBundle:Default:index',
56 '_ROUTING_param_name' => 'world',
59 '_controller' => 'AcmeBundle:Default:index',
65 'Route with params and defaults',
68 '_ROUTING_route' => 'hello',
69 '_ROUTING_param__controller' => 'AcmeBundle:Default:index',
70 '_ROUTING_param_name' => 'hugo',
71 '_ROUTING_default_name' => 'world',
75 '_controller' => 'AcmeBundle:Default:index',
80 'Route with defaults only',
83 '_ROUTING_route' => 'hello',
84 '_ROUTING_param__controller' => 'AcmeBundle:Default:index',
85 '_ROUTING_default_name' => 'world',
89 '_controller' => 'AcmeBundle:Default:index',
97 'REDIRECT__ROUTING_route' => 'hello',
98 'REDIRECT__ROUTING_param__controller' => 'AcmeBundle:Default:index',
99 'REDIRECT__ROUTING_param_name' => 'world',
102 '_controller' => 'AcmeBundle:Default:index',
108 'REDIRECT_REDIRECT_ envs',
111 'REDIRECT_REDIRECT__ROUTING_route' => 'hello',
112 'REDIRECT_REDIRECT__ROUTING_param__controller' => 'AcmeBundle:Default:index',
113 'REDIRECT_REDIRECT__ROUTING_param_name' => 'world',
116 '_controller' => 'AcmeBundle:Default:index',
122 'REDIRECT_REDIRECT_ envs',
125 'REDIRECT_REDIRECT__ROUTING_route' => 'hello',
126 'REDIRECT_REDIRECT__ROUTING_param__controller' => 'AcmeBundle:Default:index',
127 'REDIRECT_REDIRECT__ROUTING_param_name' => 'world',
130 '_controller' => 'AcmeBundle:Default:index',