@@ -108,4 +108,78 @@ public function testRouteWithSameVariableTwice()
108
108
109
109
$ compiled = $ route ->compile ();
110
110
}
111
+
112
+ /**
113
+ * @dataProvider provideCompileExtendedData
114
+ */
115
+ public function testCompileExtended ($ name , $ arguments , $ prefix , $ regex , $ variables , $ pathVariables , $ tokens , $ hostnameRegex , $ hostnameVariables , $ hostnameTokens )
116
+ {
117
+ $ r = new \ReflectionClass ('Symfony \\Component \\Routing \\Route ' );
118
+ $ route = $ r ->newInstanceArgs ($ arguments );
119
+
120
+ $ compiled = $ route ->compile ();
121
+ $ this ->assertEquals ($ prefix , $ compiled ->getStaticPrefix (), $ name .' (static prefix) ' );
122
+ $ this ->assertEquals ($ regex , str_replace (array ("\n" , ' ' ), '' , $ compiled ->getRegex ()), $ name .' (regex) ' );
123
+ $ this ->assertEquals ($ variables , $ compiled ->getVariables (), $ name .' (variables) ' );
124
+ $ this ->assertEquals ($ pathVariables , $ compiled ->getPathVariables (), $ name .' (path variables) ' );
125
+ $ this ->assertEquals ($ tokens , $ compiled ->getTokens (), $ name .' (tokens) ' );
126
+
127
+
128
+ $ this ->assertEquals ($ hostnameRegex , str_replace (array ("\n" , ' ' ), '' , $ compiled ->getHostnameRegex ()), $ name .' (hostname regex) ' );
129
+ $ this ->assertEquals ($ hostnameVariables , $ compiled ->getHostnameVariables (), $ name .' (hostname variables) ' );
130
+ $ this ->assertEquals ($ hostnameTokens , $ compiled ->getHostnameTokens (), $ name .' (hostname tokens) ' );
131
+ }
132
+
133
+ public function provideCompileExtendedData ()
134
+ {
135
+ return array (
136
+ array (
137
+ 'Route with hostname pattern ' ,
138
+ array ('/hello ' , array (), array (), array (), 'www.example.com ' ),
139
+ '/hello ' , '#^/hello$#s ' , array (), array (), array (
140
+ array ('text ' , '/hello ' ),
141
+ ),
142
+ '#^www\.example\.com$#s ' , array (), array (
143
+ array ('text ' , 'www.example.com ' ),
144
+ ),
145
+ ),
146
+ array (
147
+ 'Route with hostname pattern and some variables ' ,
148
+ array ('/hello/{name} ' , array (), array (), array (), 'www.example.{tld} ' ),
149
+ '/hello ' , '#^/hello/(?<name>[^/]+?)$#s ' , array ('tld ' , 'name ' ), array ('name ' ), array (
150
+ array ('variable ' , '/ ' , '[^/]+? ' , 'name ' ),
151
+ array ('text ' , '/hello ' ),
152
+ ),
153
+ '#^www\.example\.(?<tld>[^\.]+?)$#s ' , array ('tld ' ), array (
154
+ array ('variable ' , '. ' , '[^\.]+? ' , 'tld ' ),
155
+ array ('text ' , 'www.example ' ),
156
+ ),
157
+ ),
158
+ array (
159
+ 'Route with variable at begining of hostname ' ,
160
+ array ('/hello ' , array (), array (), array (), '{locale}.example.{tld} ' ),
161
+ '/hello ' , '#^/hello$#s ' , array ('locale ' , 'tld ' ), array (), array (
162
+ array ('text ' , '/hello ' ),
163
+ ),
164
+ '#^(?<locale>[^\.]+?)\.example\.(?<tld>[^\.]+?)$#s ' , array ('locale ' , 'tld ' ), array (
165
+ array ('variable ' , '. ' , '[^\.]+? ' , 'tld ' ),
166
+ array ('text ' , '.example ' ),
167
+ array ('variable ' , '' , '[^\.]+? ' , 'locale ' ),
168
+ ),
169
+ ),
170
+ array (
171
+ 'Route with hostname variables that has a default value ' ,
172
+ array ('/hello ' , array ('locale ' => 'a ' , 'tld ' => 'b ' ), array (), array (), '{locale}.example.{tld} ' ),
173
+ '/hello ' , '#^/hello$#s ' , array ('locale ' , 'tld ' ), array (), array (
174
+ array ('text ' , '/hello ' ),
175
+ ),
176
+ '#^(?<locale>[^\.]+?)\.example\.(?<tld>[^\.]+?)$#s ' , array ('locale ' , 'tld ' ), array (
177
+ array ('variable ' , '. ' , '[^\.]+? ' , 'tld ' ),
178
+ array ('text ' , '.example ' ),
179
+ array ('variable ' , '' , '[^\.]+? ' , 'locale ' ),
180
+ ),
181
+ ),
182
+ );
183
+ }
111
184
}
185
+
0 commit comments