function execute_filter_chain($context, $t) { $filterChain = new sfFilterChain(); $filter = new lastTestFilter(); $filter->response = $context->response; $filter->initialize($context); $filterChain->register($filter); $filter = new sfCommonFilter(); $filter->initialize($context); $filterChain->register($filter); $filter = new firstTestFilter(); $filter->response = $context->response; $filter->initialize($context); $filterChain->register($filter); $filterChain->execute(); $dom = new DomDocument('1.0', 'UTF-8'); $dom->validateOnParse = true; $dom->loadHTML($context->response->getContent()); $selector = new sfDomCssSelector($dom); return $selector; }
// sfFlashFilter has executed no code // register some flash from previous request $user->setAttribute('previous_request', 'foo', 'symfony/flash'); $user->setAttribute('every_request', 'foo', 'symfony/flash'); $filterChain->execute(); // sfFlashFilter has executed all its code $t->ok(!$user->hasAttribute('previous_request', 'symfony/flash'), '->execute() removes flash variables that have been tagged before'); $t->ok(!$user->hasAttribute('previous_request', 'symfony/flash/remove'), '->execute() removes flash variables that have been tagged before'); $t->is($user->getAttribute('this_request', null, 'symfony/flash'), 'foo', '->execute() keeps current request flash variables'); $t->is($user->getAttribute('every_request', null, 'symfony/flash'), 'foo', '->execute() flash variables that have been overriden in current request'); } } $context = new sfContext(); $user = new myUser(); $user->initialize($context); $context->user = $user; $filterChain = new sfFilterChain(); $filter = new lastTestFilter(); $filter->t = $t; $filter->user = $user; $filter->initialize($context); $filterChain->register($filter); $filter = new sfFlashFilter(); $filter->initialize($context); $filterChain->register($filter); $filter = new firstTestFilter(); $filter->t = $t; $filter->user = $user; $filter->initialize($context); $filterChain->register($filter); $filterChain->execute();