ZF-4070: Zend_Test_PHPUnit_ControllerTestCase::setQuery() GET params are erased during Zend_Test_PHPUnit_ControllerTestCase::dispatch()

Description

<?php
class Controllers_Default_IndexControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
{
    public function testIndexAction() 
    { 
        $this->request->setQuery('mr', 'proper');
        $this->dispatch('/index/index?james=bond');
        var_dump($this->request->getParams());

=====echoes======

....................................array(4) {
  ["controller"]=>
  string(5) "index"
  ["action"]=>
  string(5) "index"
  ["module"]=>
  string(7) "default"
  ["james"]=>
  string(4) "bond"
}

Why 'mr' GET param is not set?

Comments

The parameter is not set because you passed parameters via the query string; these overwrite those previously set with setQuery().

Either set all GET parameters using setQuery() or pass them as part of the URL to dispatch.

The following better demonstrates the issue:


    public function testIndexAction()
    {
        $this->request->setQuery('mr', 'proper')
                      ->setQuery('james', 'bond');
        $this->dispatch('/index/index');
        $this->fail(var_export($this->request->getParams(), 1));
    }

The expected result would show both the 'mr' and 'james' parameters in the request. However, these are not present. exporting getQuery() results in an empty array as well.

Scheduling for next mini release (1.6.1)

Fixed in trunk and 1.6 release branch; will release with 1.6.1