Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

convenience wrapper for HTTP PATCH in HttpSocket class.

  • Loading branch information...
commit 679177b8f30017beeb8df343e5c8ea376b387733 1 parent a079ca3
@fahad19 fahad19 authored
View
13 lib/Cake/Network/Http/HttpSocket.php
@@ -495,6 +495,19 @@ public function put($uri = null, $data = array(), $request = array()) {
}
/**
+ * 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.
*
* @param string|array $uri URI to request (see {@link _parseUri()})
View
24 lib/Cake/Test/Case/Network/Http/HttpSocketTest.php
@@ -1148,6 +1148,30 @@ public function testPut() {
}
/**
+ * 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
*
* @return void
Please sign in to comment.
Something went wrong with that request. Please try again.