Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1404434

Browse files
committed
Re-add the 'testSerializedRepresentationKeepsWorking' test, but update the regex
1 parent 5672f1c commit 1404434

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/Symfony/Component/Routing/Tests/RouteTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,22 @@ public function testSerializeWhenCompiled()
264264
$this->assertEquals($route, $unserialized);
265265
$this->assertNotSame($route, $unserialized);
266266
}
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+
}
267285
}

0 commit comments

Comments
 (0)