浏览代码

Adds isPatch method and unit test for PATCH request (#511)

Frank Brückner 11 年之前
父节点
当前提交
dea39d4770
共有 2 个文件被更改,包括 16 次插入0 次删除
  1. 14 0
      library/Zend/Controller/Request/Http.php
  2. 2 0
      tests/Zend/Controller/Request/HttpTestCaseTest.php

+ 14 - 0
library/Zend/Controller/Request/Http.php

@@ -918,6 +918,20 @@ class Zend_Controller_Request_Http extends Zend_Controller_Request_Abstract
     }
 
     /**
+     * Was the request made by PATCH?
+     *
+     * @return boolean
+     */
+    public function isPatch()
+    {
+        if ('PATCH' == $this->getMethod()) {
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
      * Is the request a Javascript XMLHttpRequest?
      *
      * Should work with Prototype/Script.aculo.us, possibly others.

+ 2 - 0
tests/Zend/Controller/Request/HttpTestCaseTest.php

@@ -307,6 +307,8 @@ class Zend_Controller_Request_HttpTestCaseTest extends PHPUnit_Framework_TestCas
         $this->assertTrue($this->request->isHead());
         $this->request->setMethod('DELETE');
         $this->assertTrue($this->request->isDelete());
+        $this->request->setMethod('PATCH');
+        $this->assertTrue($this->request->isPatch());
     }
 }