Пример #1
0
$t->is($request->getMethod(), 'GET', '->getMethod() returns GET if the method is GET');
$_SERVER['REQUEST_METHOD'] = 'PUT';
$request = new myRequest($dispatcher);
$t->is($request->getMethod(), 'PUT', '->getMethod() returns PUT if the method is PUT');
$_SERVER['REQUEST_METHOD'] = 'PUT';
$_SERVER['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
$request = new myRequest($dispatcher, array(), array(), array('content_custom_only_for_test' => 'first=value'));
$t->is($request->getPostParameter('first'), 'value', '->getMethod() set POST parameters from parsed content if content type is "application/x-www-form-urlencoded" and the method is PUT');
unset($_POST['first'], $_SERVER['CONTENT_TYPE']);
$_SERVER['REQUEST_METHOD'] = 'DELETE';
$request = new myRequest($dispatcher);
$t->is($request->getMethod(), 'DELETE', '->getMethod() returns DELETE if the method is DELETE');
$_SERVER['REQUEST_METHOD'] = 'DELETE';
$_SERVER['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
$request = new myRequest($dispatcher, array(), array(), array('content_custom_only_for_test' => 'first=value'));
$t->is($request->getPostParameter('first'), 'value', '->getMethod() set POST parameters from parsed content if content type is "application/x-www-form-urlencoded" and the method is DELETE');
unset($_POST['first'], $_SERVER['CONTENT_TYPE']);
$_SERVER['REQUEST_METHOD'] = 'HEAD';
$request = new myRequest($dispatcher);
$t->is($request->getMethod(), 'HEAD', '->getMethod() returns DELETE if the method is HEAD');
$_SERVER['REQUEST_METHOD'] = 'POST';
$_POST['sf_method'] = 'PUT';
$request = new myRequest($dispatcher);
$t->is($request->getMethod(), 'PUT', '->getMethod() returns the "sf_method" parameter value if it exists and if the method is POST');
$_SERVER['REQUEST_METHOD'] = 'GET';
$_POST['sf_method'] = 'PUT';
$request = new myRequest($dispatcher);
$t->is($request->getMethod(), 'GET', '->getMethod() returns the "sf_method" parameter value if it exists and if the method is POST');
$_SERVER['REQUEST_METHOD'] = 'POST';
unset($_POST['sf_method']);
$request = new myRequest($dispatcher);