ZF-10374: Zend_Controller_Response::setRawHeader() is untestable with Zend_Test_PHPUnit_ControllerTestCase

Description

I'm using {{Zend_Controller_Response::setRawHeader()}} in one of my actions:


$this->getResponse()->setRawHeader('HTTP/1.1 300 Multiple Choices');

In my test case ({{Zend_Test_PHPUnit_ControllerTestCase}}), I'm using the following assertion:


$this->assertResponseCode(300);

This however does not work, I dumped {{Zend_Controller_Response_HttpTestCase}} and noticed the following:


   '_headersRaw' => 
  array (
    0 => 'HTTP/1.1 300 Multiple Choices',
  ),
   '_httpResponseCode' => 200,
   '_isRedirect' => false,
   '_renderExceptions' => false,
   'headersSentThrowsException' => true,
))

So the assertion finds {{200}}.

When I {{curl}} my action ({{curl -I http://example.org/controller/action}} I receive 300 as well. So it seems to work indeed. However, I'm trying to avoid HTTP calls here.

The quickfix is the following:


$this->getResponse()->setRawHeader('HTTP/1.1 300 Multiple Choices');
$this->getResponse()->setHttpResponseCode(300);

Comments

Zend_Controller_Response_Http exhibits same behavior. Is this an issue which should be fixed in ZF1? Or is it sufficient to update the manual to note that the HTTP status code cannot be set using {{setRawHeader}} alone?

I don't know – IMHO or ideally this would be fixed so setRawHeader() parses the code and end of story. I don't like writing code specific for tests.

I've almost made my peace with Zend_Test since it requires an older version of PHPUnit due to PHPUnit's constant BC breaks. It's a huge inconvenience for development since you have to maintain two versions of PHPUnit and developers need to use it anyway and running tests manually is already a problem and maintaining two setups blows.

Maybe I find some time to update Zend_Test or write a ZendX_Test? Would that be still taken into the tree if I did?