Ejemplo n.º 1
0
function configureRouting($event)
{
    $event->getSubject()->connect('first', new sfRoute('/first'));
    $event->getSubject()->connect('second', new sfRoute('/', array()));
}
$cache = new sfLocalmemCache();
// cache-in
$rCached = new sfPatternRoutingTest($dispatcher, $cache, array_merge($options, array('lazy_routes_deserialize' => true)));
$rCached->parse('/first');
$t->isnt($rCached->findRoute('/first'), false, '->findRoute() finds the route with lazy config cache activated');
$t->is($rCached->findRoute('/no/match/found'), null, '->findRoute() returns null on non-matching route');
// cache-hit
$rCached = new sfPatternRoutingTest($dispatcher, $cache, array_merge($options, array('lazy_routes_deserialize' => true)));
$rCached->parse('/first');
$t->isnt($rCached->findRoute('/first'), false, '->findRoute() finds the route with lazy config cache activated');
$t->is($rCached->isRouteLoaded('second'), false, '->isRouteLoaded() The second route is not loaded');
$t->is($rCached->findRoute('/no/match/found'), null, '->findRoute() returns null on non-matching route');
$t->is($rCached->findRoute('/no/match/found'), null, '->findRoute() returns null on non-matching route');
$t->is($rCached->isRouteLoaded('second'), true, '->isRouteLoaded() The last route is loaded after a full routes scan');
$rCached = new sfPatternRoutingTest($dispatcher, $cache, array_merge($options, array('lazy_routes_deserialize' => true)));
$t->is($rCached->generate('second'), '/', '->generate() works on a lazy route');
$rCached = new sfPatternRoutingTest($dispatcher, $cache, array_merge($options, array('lazy_routes_deserialize' => true)));
$routes = $rCached->getRoutes();
try {
    foreach ($routes as $route) {
        if (!is_object($route)) {
            throw new Exception();
        }
    }
    $t->pass('->getRoutes() does not return lazy routes');
} catch (Exception $e) {