]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php
twig implementation
[github/wallabag/wallabag.git] / vendor / symfony / routing / Symfony / Component / Routing / Tests / Matcher / ApacheUrlMatcherTest.php
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Routing\Tests\Matcher;
13
14 use Symfony\Component\Routing\RouteCollection;
15 use Symfony\Component\Routing\RequestContext;
16 use Symfony\Component\Routing\Matcher\ApacheUrlMatcher;
17
18 class ApacheUrlMatcherTest extends \PHPUnit_Framework_TestCase
19 {
20 protected $server;
21
22 protected function setUp()
23 {
24 $this->server = $_SERVER;
25 }
26
27 protected function tearDown()
28 {
29 $_SERVER = $this->server;
30 }
31
32 /**
33 * @dataProvider getMatchData
34 */
35 public function testMatch($name, $pathinfo, $server, $expect)
36 {
37 $collection = new RouteCollection();
38 $context = new RequestContext();
39 $matcher = new ApacheUrlMatcher($collection, $context);
40
41 $_SERVER = $server;
42
43 $result = $matcher->match($pathinfo, $server);
44 $this->assertSame(var_export($expect, true), var_export($result, true));
45 }
46
47 public function getMatchData()
48 {
49 return array(
50 array(
51 'Simple route',
52 '/hello/world',
53 array(
54 '_ROUTING_route' => 'hello',
55 '_ROUTING_param__controller' => 'AcmeBundle:Default:index',
56 '_ROUTING_param_name' => 'world',
57 ),
58 array(
59 '_controller' => 'AcmeBundle:Default:index',
60 'name' => 'world',
61 '_route' => 'hello',
62 ),
63 ),
64 array(
65 'Route with params and defaults',
66 '/hello/hugo',
67 array(
68 '_ROUTING_route' => 'hello',
69 '_ROUTING_param__controller' => 'AcmeBundle:Default:index',
70 '_ROUTING_param_name' => 'hugo',
71 '_ROUTING_default_name' => 'world',
72 ),
73 array(
74 'name' => 'hugo',
75 '_controller' => 'AcmeBundle:Default:index',
76 '_route' => 'hello',
77 ),
78 ),
79 array(
80 'Route with defaults only',
81 '/hello',
82 array(
83 '_ROUTING_route' => 'hello',
84 '_ROUTING_param__controller' => 'AcmeBundle:Default:index',
85 '_ROUTING_default_name' => 'world',
86 ),
87 array(
88 'name' => 'world',
89 '_controller' => 'AcmeBundle:Default:index',
90 '_route' => 'hello',
91 ),
92 ),
93 array(
94 'REDIRECT_ envs',
95 '/hello/world',
96 array(
97 'REDIRECT__ROUTING_route' => 'hello',
98 'REDIRECT__ROUTING_param__controller' => 'AcmeBundle:Default:index',
99 'REDIRECT__ROUTING_param_name' => 'world',
100 ),
101 array(
102 '_controller' => 'AcmeBundle:Default:index',
103 'name' => 'world',
104 '_route' => 'hello',
105 ),
106 ),
107 array(
108 'REDIRECT_REDIRECT_ envs',
109 '/hello/world',
110 array(
111 'REDIRECT_REDIRECT__ROUTING_route' => 'hello',
112 'REDIRECT_REDIRECT__ROUTING_param__controller' => 'AcmeBundle:Default:index',
113 'REDIRECT_REDIRECT__ROUTING_param_name' => 'world',
114 ),
115 array(
116 '_controller' => 'AcmeBundle:Default:index',
117 'name' => 'world',
118 '_route' => 'hello',
119 ),
120 ),
121 array(
122 'REDIRECT_REDIRECT_ envs',
123 '/hello/world',
124 array(
125 'REDIRECT_REDIRECT__ROUTING_route' => 'hello',
126 'REDIRECT_REDIRECT__ROUTING_param__controller' => 'AcmeBundle:Default:index',
127 'REDIRECT_REDIRECT__ROUTING_param_name' => 'world',
128 ),
129 array(
130 '_controller' => 'AcmeBundle:Default:index',
131 'name' => 'world',
132 '_route' => 'hello',
133 ),
134 ),
135 );
136 }
137 }