Browse files

Adding net\http\Service::patch() method.

  • Loading branch information...
1 parent 2576ec8 commit d0491b65a88284c0d72a57bc2c5669b3c9189b9a @ppadron ppadron committed Sep 18, 2012
Showing with 22 additions and 6 deletions.
  1. +12 −0 net/http/Service.php
  2. +10 −6 tests/cases/net/http/ServiceTest.php
View
12 net/http/Service.php
@@ -165,6 +165,18 @@ public function put($path = null, $data = array(), array $options = array()) {
}
/**
+ * Send PATCH request.
+ *
+ * @param string $path
+ * @param array $data
+ * @param array $options
+ * @return string
+ */
+ public function patch($path = null, $data = array(), array $options = array()) {
+ return $this->send(__FUNCTION__, $path, $data, $options);
+ }
+
+ /**
* Send DELETE request.
*
* @param string $path
View
16 tests/cases/net/http/ServiceTest.php
@@ -248,13 +248,8 @@ public function testSendConfiguringConnection() {
$this->assertEqual('someValue', $config['someKey']);
}
- public function testMagicMethod() {
+ public function testPatchMethod() {
$http = new Service($this->_testConfig);
- $response = $http->patch('some-path/stuff');
- $expected = "http://localhost:80/some-path/stuff";
- $result = $http->last->request->to('url');
- $this->assertEqual($expected, $result);
-
$response = $http->patch(
'some-path/stuff',
array('someData' => 'someValue'),
@@ -266,6 +261,15 @@ public function testMagicMethod() {
$this->assertEqual('someData=someValue', $result->body());
}
+ public function testMagicMethod() {
+ $http = new Service($this->_testConfig);
+ $response = $http->magic('some-path/stuff');
+ $expected = "http://localhost:80/some-path/stuff";
+ $result = $http->last->request;
+ $this->assertEqual($expected, $result->to('url'));
+ $this->assertEqual('MAGIC', $result->method);
+ }
+
public function testDigestAuth() {
$this->_testConfig += array('auth' => 'digest', 'username' => 'gwoo', 'password' => 'li3');
$http = new Service($this->_testConfig);

0 comments on commit d0491b6

Please sign in to comment.