Zend Framework

Zend_Test_PHPUnit_ControllerTestCase::setQuery() GET params are erased during Zend_Test_PHPUnit_ControllerTestCase::dispatch()

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.6.0RC2
  • Fix Version/s: 1.6.1
  • Component/s: Zend_Test_PHPUnit
  • Labels:
    None
  • Fix Version Priority:
    Must Have

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?

Activity

Hide
Matthew Weier O'Phinney added a comment -

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.

Show
Matthew Weier O'Phinney added a comment - 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.
Hide
Matthew Weier O'Phinney added a comment -

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.

Show
Matthew Weier O'Phinney added a comment - 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.
Hide
Matthew Weier O'Phinney added a comment -

Scheduling for next mini release (1.6.1)

Show
Matthew Weier O'Phinney added a comment - Scheduling for next mini release (1.6.1)
Hide
Matthew Weier O'Phinney added a comment -

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

Show
Matthew Weier O'Phinney added a comment - Fixed in trunk and 1.6 release branch; will release with 1.6.1

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
15m
Original Estimate - 15 minutes
Remaining:
15m
Remaining Estimate - 15 minutes
Logged:
Not Specified
Time Spent - Not Specified