Support for PATCH method in forms
This commit is contained in:
parent
06da573d04
commit
2dd4bf1283
@ -582,6 +582,7 @@ class Form implements \IteratorAggregate, FormInterface
|
|||||||
case 'POST':
|
case 'POST':
|
||||||
case 'PUT':
|
case 'PUT':
|
||||||
case 'DELETE':
|
case 'DELETE':
|
||||||
|
case 'PATCH':
|
||||||
if ('' === $this->getName()) {
|
if ('' === $this->getName()) {
|
||||||
$data = array_replace_recursive(
|
$data = array_replace_recursive(
|
||||||
$request->request->all(),
|
$request->request->all(),
|
||||||
|
@ -823,6 +823,7 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
|||||||
array('POST'),
|
array('POST'),
|
||||||
array('PUT'),
|
array('PUT'),
|
||||||
array('DELETE'),
|
array('DELETE'),
|
||||||
|
array('PATCH'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -585,7 +585,19 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateFromGlobals()
|
public static function overloadedMethodProvider()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('PUT'),
|
||||||
|
array('DELETE'),
|
||||||
|
array('PATCH'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider overloadedMethodProvider
|
||||||
|
*/
|
||||||
|
public function testCreateFromGlobals($method)
|
||||||
{
|
{
|
||||||
$_GET['foo1'] = 'bar1';
|
$_GET['foo1'] = 'bar1';
|
||||||
$_POST['foo2'] = 'bar2';
|
$_POST['foo2'] = 'bar2';
|
||||||
@ -602,19 +614,19 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
unset($_GET['foo1'], $_POST['foo2'], $_COOKIE['foo3'], $_FILES['foo4'], $_SERVER['foo5']);
|
unset($_GET['foo1'], $_POST['foo2'], $_COOKIE['foo3'], $_FILES['foo4'], $_SERVER['foo5']);
|
||||||
|
|
||||||
$_SERVER['REQUEST_METHOD'] = 'PUT';
|
$_SERVER['REQUEST_METHOD'] = $method;
|
||||||
$_SERVER['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
|
$_SERVER['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
|
||||||
$request = RequestContentProxy::createFromGlobals();
|
$request = RequestContentProxy::createFromGlobals();
|
||||||
$this->assertEquals('PUT', $request->getMethod());
|
$this->assertEquals($method, $request->getMethod());
|
||||||
$this->assertEquals('mycontent', $request->request->get('content'));
|
$this->assertEquals('mycontent', $request->request->get('content'));
|
||||||
|
|
||||||
unset($_SERVER['REQUEST_METHOD'], $_SERVER['CONTENT_TYPE']);
|
unset($_SERVER['REQUEST_METHOD'], $_SERVER['CONTENT_TYPE']);
|
||||||
|
|
||||||
$_POST['_method'] = 'PUT';
|
$_POST['_method'] = $method;
|
||||||
$_POST['foo6'] = 'bar6';
|
$_POST['foo6'] = 'bar6';
|
||||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||||
$request = Request::createFromGlobals();
|
$request = Request::createFromGlobals();
|
||||||
$this->assertEquals('PUT', $request->getMethod());
|
$this->assertEquals($method, $request->getMethod());
|
||||||
$this->assertEquals('bar6', $request->request->get('foo6'));
|
$this->assertEquals('bar6', $request->request->get('foo6'));
|
||||||
|
|
||||||
unset($_POST['_method'], $_POST['foo6'], $_SERVER['REQUEST_METHOD']);
|
unset($_POST['_method'], $_POST['foo6'], $_SERVER['REQUEST_METHOD']);
|
||||||
|
Reference in New Issue
Block a user