Просмотр исходного кода

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

Frank Brückner 11 лет назад
Родитель
Сommit
dea39d4770

+ 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());
     }
 }