Преглед изворни кода

ZF-3750: honor param sources; applied patch from Mike Willibanks

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19076 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew пре 16 година
родитељ
комит
8867c37cdf
2 измењених фајлова са 24 додато и 1 уклоњено
  1. 1 1
      library/Zend/Controller/Request/Http.php
  2. 23 0
      tests/Zend/Controller/Request/HttpTest.php

+ 1 - 1
library/Zend/Controller/Request/Http.php

@@ -727,7 +727,7 @@ class Zend_Controller_Request_Http extends Zend_Controller_Request_Abstract
      * Retrieve an array of parameters
      *
      * Retrieves a merged array of parameters, with precedence of userland
-     * params (see {@link setParam()}), $_GET, $POST (i.e., values in the
+     * params (see {@link setParam()}), $_GET, $_POST (i.e., values in the
      * userland params will take precedence over all others).
      *
      * @return array

+ 23 - 0
tests/Zend/Controller/Request/HttpTest.php

@@ -255,6 +255,29 @@ class Zend_Controller_Request_HttpTest extends PHPUnit_Framework_TestCase
         $this->assertSame($params, array_intersect_assoc($params, $received));
     }
 
+    /**
+     * @group ZF-3750
+     */
+    public function testGetParamsWithGetOrPost()
+    {
+        $_GET = array(
+            'get' => true
+        );
+        $_POST = array(
+            'post' => true
+        );
+
+        $this->_request->setParamSources(array('_GET'));
+        $params = $this->_request->getParams();
+        $this->assertArrayHasKey('get', $params);
+        $this->assertArrayNotHasKey('post', $params);
+
+        $this->_request->setParamSources(array('_POST'));
+        $params = $this->_request->getParams();
+        $this->assertArrayHasKey('post', $params);
+        $this->assertArrayNotHasKey('get', $params);
+    }
+
     public function testConstructSetsRequestUri()
     {
         $_SERVER['REQUEST_URI'] = '/mycontroller/myaction?foo=bar';