File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
src/Symfony/Component/Routing/Tests Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -264,4 +264,22 @@ public function testSerializeWhenCompiled()
264
264
$ this ->assertEquals ($ route , $ unserialized );
265
265
$ this ->assertNotSame ($ route , $ unserialized );
266
266
}
267
+
268
+ /**
269
+ * Tests that the serialized representation of a route in one symfony version
270
+ * also works in later symfony versions, i.e. the unserialized route is in the
271
+ * same state as another, semantically equivalent, route.
272
+ */
273
+ public function testSerializedRepresentationKeepsWorking ()
274
+ {
275
+ $ serialized = 'C:31:"Symfony\Component\Routing\Route":959:{a:9:{s:4:"path";s:13:"/prefix/{foo}";s:4:"host";s:20:"{locale}.example.net";s:8:"defaults";a:1:{s:3:"foo";s:7:"default";}s:12:"requirements";a:1:{s:3:"foo";s:3:"\d+";}s:7:"options";a:1:{s:14:"compiler_class";s:39:"Symfony\Component\Routing\RouteCompiler";}s:7:"schemes";a:0:{}s:7:"methods";a:0:{}s:9:"condition";s:0:"";s:8:"compiled";C:39:"Symfony\Component\Routing\CompiledRoute":571:{a:8:{s:4:"vars";a:2:{i:0;s:6:"locale";i:1;s:3:"foo";}s:11:"path_prefix";s:7:"/prefix";s:10:"path_regex";s:31:"#^/prefix(?:/(?P<foo>\d+))?$#sD";s:11:"path_tokens";a:2:{i:0;a:4:{i:0;s:8:"variable";i:1;s:1:"/";i:2;s:3:"\d+";i:3;s:3:"foo";}i:1;a:2:{i:0;s:4:"text";i:1;s:7:"/prefix";}}s:9:"path_vars";a:1:{i:0;s:3:"foo";}s:10:"host_regex";s:40:"#^(?P<locale>[^\.]++)\.example\.net$#sDi";s:11:"host_tokens";a:2:{i:0;a:2:{i:0;s:4:"text";i:1;s:12:".example.net";}i:1;a:4:{i:0;s:8:"variable";i:1;s:0:"";i:2;s:7:"[^\.]++";i:3;s:6:"locale";}}s:9:"host_vars";a:1:{i:0;s:6:"locale";}}}}} ' ;
276
+ $ unserialized = unserialize ($ serialized );
277
+
278
+ $ route = new Route ('/prefix/{foo} ' , array ('foo ' => 'default ' ), array ('foo ' => '\d+ ' ));
279
+ $ route ->setHost ('{locale}.example.net ' );
280
+ $ route ->compile ();
281
+
282
+ $ this ->assertEquals ($ route , $ unserialized );
283
+ $ this ->assertNotSame ($ route , $ unserialized );
284
+ }
267
285
}
You can’t perform that action at this time.
0 commit comments