示例#1
0
$request->setRelativeUrlRoot('toto');
$t->is($request->getRelativeUrlRoot(), 'toto', '->getRelativeUrlRoot() return previously set relative url root');
// ->addRequestParameters() ->getRequestParameters() ->fixParameters()
$t->diag('->addRequestParameters() ->getRequestParameters() ->fixParameters()');
$request = new myRequest($dispatcher);
$t->is($request->getRequestParameters(), array(), '->getRequestParameters() returns the request parameters default array');
$request->addRequestParameters(array('test' => 'test'));
$t->is($request->getRequestParameters(), array('test' => 'test'), '->getRequestParameters() returns the request parameters');
$request->addRequestParameters(array('test' => 'test'));
$t->is($request->getRequestParameters(), array('test' => 'test'), '->getRequestParameters() returns the request parameters allready exists');
$request->addRequestParameters(array('_sf_ignore_cache' => 1, 'test2' => 'test2'));
$t->is($request->getRequestParameters(), array('test' => 'test', 'test2' => 'test2', '_sf_ignore_cache' => 1), '->getRequestParameters() returns the request parameters check fixParameters call for special _sf_ params');
$t->is($request->getAttribute('sf_ignore_cache'), 1, '->getAttribute() check special param is set as attribute');
// ->getUrlParameter
$t->diag('->getUrlParameter()');
$t->is($request->getUrlParameter('test'), 'test', '->getUrlParameter() returns URL parameter by name');
// ->checkCSRFProtection()
$t->diag('->checkCSRFProtection()');
class BaseForm extends sfForm
{
    public function getCSRFToken($secret = null)
    {
        return '==TOKEN==';
    }
}
sfForm::enableCSRFProtection();
$request = new myRequest($dispatcher);
try {
    $request->checkCSRFProtection();
    $t->fail('->checkCSRFProtection() throws a validator error if CSRF protection fails');
} catch (sfValidatorErrorSchema $error) {