mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Merge pull request #1326 from fahad19/http-patch
convenience wrapper for HTTP PATCH in HttpSocket class.
This commit is contained in:
commit
59646aa30a
2 changed files with 37 additions and 0 deletions
|
@ -496,6 +496,19 @@ class HttpSocket extends CakeSocket {
|
|||
return $this->request($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Issues a PATCH request to the specified URI, query, and request.
|
||||
*
|
||||
* @param string|array $uri URI to request, See HttpSocket::_parseUri()
|
||||
* @param array $data Array of PATCH data keys and values.
|
||||
* @param array $request An indexed array with indexes such as 'method' or uri
|
||||
* @return mixed Result of request
|
||||
*/
|
||||
public function patch($uri = null, $data = array(), $request = array()) {
|
||||
$request = Hash::merge(array('method' => 'PATCH', 'uri' => $uri, 'body' => $data), $request);
|
||||
return $this->request($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Issues a DELETE request to the specified URI, query, and request.
|
||||
*
|
||||
|
|
|
@ -1149,6 +1149,30 @@ class HttpSocketTest extends CakeTestCase {
|
|||
$this->RequestSocket->put('http://www.google.com/', null, array('line' => 'Hey Server'));
|
||||
}
|
||||
|
||||
/**
|
||||
* testPatch
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPatch() {
|
||||
$this->RequestSocket->reset();
|
||||
$this->RequestSocket->expects($this->at(0))
|
||||
->method('request')
|
||||
->with(array('method' => 'PATCH', 'uri' => 'http://www.google.com/', 'body' => array()));
|
||||
|
||||
$this->RequestSocket->expects($this->at(1))
|
||||
->method('request')
|
||||
->with(array('method' => 'PATCH', 'uri' => 'http://www.google.com/', 'body' => array('Foo' => 'bar')));
|
||||
|
||||
$this->RequestSocket->expects($this->at(2))
|
||||
->method('request')
|
||||
->with(array('method' => 'PATCH', 'uri' => 'http://www.google.com/', 'body' => null, 'line' => 'Hey Server'));
|
||||
|
||||
$this->RequestSocket->patch('http://www.google.com/');
|
||||
$this->RequestSocket->patch('http://www.google.com/', array('Foo' => 'bar'));
|
||||
$this->RequestSocket->patch('http://www.google.com/', null, array('line' => 'Hey Server'));
|
||||
}
|
||||
|
||||
/**
|
||||
* testDelete
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue