Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix for issue #3945, and fix for PUT with request content

  • Loading branch information...
commit 7d7fa4f77120b825e26aadeca05bd2d5274e2c4d 1 parent f2b26d9
Tim Roediger superdweebie authored
17 library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php
View
@@ -19,7 +19,6 @@
use Zend\Stdlib\Parameters;
use Zend\Stdlib\ResponseInterface;
use Zend\Uri\Http as HttpUri;
-use Zend\View\Helper\Placeholder;
abstract class AbstractControllerTestCase extends PHPUnit_Framework_TestCase
{
@@ -217,11 +216,13 @@ public function url($url, $method = HttpRequest::METHOD_GET, $params = array())
} elseif ($method == HttpRequest::METHOD_GET) {
$query = array_merge($query, $params);
} elseif ($method == HttpRequest::METHOD_PUT) {
- array_walk($params,
- function(&$item, $key) { $item = $key . '=' . $item; }
- );
- $content = implode('&', $params);
- $request->setContent($content);
+ if (!$content = $request->getContent()){
+ array_walk($params,
+ function(&$item, $key) { $item = $key . '=' . $item; }
+ );
+ $content = implode('&', $params);
+ $request->setContent($content);
+ }
} elseif ($params) {
trigger_error(
'Additional params is only supported by GET, POST and PUT HTTP method',
@@ -251,6 +252,10 @@ function(&$item, $key) { $item = $key . '=' . $item; }
*/
public function dispatch($url, $method = HttpRequest::METHOD_GET, $params = array())
{
+ if ($requestMethod = $this->getRequest()->getMethod()){
+ $method = $requestMethod;
+ }
+
$this->url($url, $method, $params);
$this->getApplication()->run();
Please sign in to comment.
Something went wrong with that request. Please try again.