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 PHPUnit\Framework\TestCase;
15 use Symfony\Component\Routing\RouteCollection;
16 use Symfony\Component\Routing\RequestContext;
17 use Symfony\Component\Routing\Matcher\ApacheUrlMatcher;
22 class LegacyApacheUrlMatcherTest extends TestCase
26 protected function setUp()
28 $this->server = $_SERVER;
31 protected function tearDown()
33 $_SERVER = $this->server;
37 * @dataProvider getMatchData
39 public function testMatch($name, $pathinfo, $server, $expect)
41 $collection = new RouteCollection();
42 $context = new RequestContext();
43 $matcher = new ApacheUrlMatcher($collection, $context);
47 $result = $matcher->match($pathinfo);
48 $this->assertSame(var_export($expect, true), var_export($result, true));
51 public function getMatchData()
58 '_ROUTING_route' => 'hello',
59 '_ROUTING_param__controller' => 'AcmeBundle:Default:index',
60 '_ROUTING_param_name' => 'world',
63 '_controller' => 'AcmeBundle:Default:index',
69 'Route with params and defaults',
72 '_ROUTING_route' => 'hello',
73 '_ROUTING_param__controller' => 'AcmeBundle:Default:index',
74 '_ROUTING_param_name' => 'hugo',
75 '_ROUTING_default_name' => 'world',
79 '_controller' => 'AcmeBundle:Default:index',
84 'Route with defaults only',
87 '_ROUTING_route' => 'hello',
88 '_ROUTING_param__controller' => 'AcmeBundle:Default:index',
89 '_ROUTING_default_name' => 'world',
93 '_controller' => 'AcmeBundle:Default:index',
98 'Redirect with many ignored attributes',
99 '/legacy/{cat1}/{cat2}/{id}.html',
101 '_ROUTING_route' => 'product_view',
102 '_ROUTING_param__controller' => 'FrameworkBundle:Redirect:redirect',
103 '_ROUTING_default_ignoreAttributes[0]' => 'attr_a',
104 '_ROUTING_default_ignoreAttributes[1]' => 'attr_b',
107 'ignoreAttributes' => array('attr_a', 'attr_b'),
108 '_controller' => 'FrameworkBundle:Redirect:redirect',
109 '_route' => 'product_view',
116 'REDIRECT__ROUTING_route' => 'hello',
117 'REDIRECT__ROUTING_param__controller' => 'AcmeBundle:Default:index',
118 'REDIRECT__ROUTING_param_name' => 'world',
121 '_controller' => 'AcmeBundle:Default:index',
127 'REDIRECT_REDIRECT_ envs',
130 'REDIRECT_REDIRECT__ROUTING_route' => 'hello',
131 'REDIRECT_REDIRECT__ROUTING_param__controller' => 'AcmeBundle:Default:index',
132 'REDIRECT_REDIRECT__ROUTING_param_name' => 'world',
135 '_controller' => 'AcmeBundle:Default:index',
141 'REDIRECT_REDIRECT_ envs',
144 'REDIRECT_REDIRECT__ROUTING_route' => 'hello',
145 'REDIRECT_REDIRECT__ROUTING_param__controller' => 'AcmeBundle:Default:index',
146 'REDIRECT_REDIRECT__ROUTING_param_name' => 'world',
149 '_controller' => 'AcmeBundle:Default:index',