/**
  * Ensures that the postDispatch() method of the controller is even called
  * if the response object contains a redirect.
  *
  * This behavior was introduced with ZF-7496 {@link http://framework.zend.com/issues/browse/ZF-7496}.
  */
 public function testPostDispatchIsCalledEvenOnRedirect()
 {
     $this->response->setRedirect('http://example.com');
     $this->dispatch('foo');
     $message = 'Post dispatch hook should have been called.';
     $this->assertTrue($this->controller->wasCalled('postDispatch'), $message);
 }
Beispiel #2
0
 /**
  * output body
  *
  * @return void
  */
 public function outputBody()
 {
     $callback = $this->outputBodyCallback;
     if (is_callable($callback)) {
         $this->testCallbackCallCount++;
         ob_start();
         $callback($this, self::CHUNK_SIZE);
         $this->testCallbackOutput[] = ob_get_clean();
     } else {
         return parent::outputBody();
     }
 }
Beispiel #3
0
 /**
  * Check to see if content is NOT matched by regex in selected nodes
  *
  * @param  Zend_Controller_Response_HttpTestCase $response
  * @param  string $pattern
  * @return bool
  */
 protected function _notRegex($response, $pattern)
 {
     if (!$response->isRedirect()) {
         return true;
     }
     $headers = $response->sendHeaders();
     $redirect = $headers['location'];
     $redirect = str_replace('Location: ', '', $redirect);
     return !preg_match($pattern, $redirect);
 }
Beispiel #4
0
 /**
  * @return array
  */
 public function htmlResponseProvider()
 {
     $data = array();
     $response1 = new Zend_Controller_Response_HttpTestCase();
     $response1->setHeader('Content-Type', 'text/html');
     $data[] = array($response1, true, 'Content-Type: text/html');
     $response2 = new Zend_Controller_Response_HttpTestCase();
     $response2->setHeader('Content-Type', 'text/xml');
     $data[] = array($response2, false, 'Content-Type: text/xml');
     $response3 = new Zend_Controller_Response_HttpTestCase();
     $response3->setRawHeader('Content-Type: text/html');
     $data[] = array($response3, true, 'Content-Type: text/html');
     $response4 = new Zend_Controller_Response_HttpTestCase();
     $response4->setRawHeader('Content-Type: text/html; charset=utf-8');
     $data[] = array($response4, true, 'Content-Type: text/html; charset=utf-8');
     $response5 = new Zend_Controller_Response_HttpTestCase();
     $response5->setHeader('Content-Type', 'text/html; charset=utf-8');
     $data[] = array($response5, true, 'Content-Type: text/html; charset=utf-8');
     $response6 = new Zend_Controller_Response_HttpTestCase();
     $response6->setRawHeader('ConTent-type: TEXT/HTML; charset=utf-8');
     $data[] = array($response6, true, 'ConTent-type: TEXT/HTML; charset=utf-8');
     $response7 = new Zend_Controller_Response_HttpTestCase();
     $response7->setRawHeader('Content-Type: text/xml');
     $data[] = array($response7, false, 'Content-Type: text/xml');
     return $data;
 }
 /**
  * Creates a pre-configured response for testing.
  *
  * @return Zend_Controller_Response_HttpTestCase
  */
 protected function createResponse()
 {
     $response = new Zend_Controller_Response_HttpTestCase();
     $response->setHttpResponseCode(200);
     $response->setHeader('Content-Type', 'text/html', true);
     $response->setHeader('X-Multiple-Times', 'a', false);
     $response->setHeader('X-Multiple-Times', 'b', false);
     $response->setHeader('X-Multiple-Times', 'c', false);
     $response->setBody('Hello world!');
     return $response;
 }
Beispiel #6
0
 public function sendResponse()
 {
     Mage::dispatchEvent('http_response_send_before', array('response' => $this));
     return parent::sendResponse();
 }
 /**
  * @dataProvider validCookieWithInfoProvider
  */
 public function testAddingAsRawHeaderToResponseObject($cStr, $info, $expected)
 {
     $response = new Zend_Controller_Response_HttpTestCase();
     $cookie = Zend_Http_Header_SetCookie::fromString($cStr);
     $response->setRawHeader($cookie);
     $this->assertContains((string) $cookie, $response->sendHeaders());
 }
 /**
  * @group GH-295
  */
 public function testMultipleCookies()
 {
     $setCookieHeader = new Zend_Http_Header_SetCookie('othername1', 'othervalue1');
     $appendCookie = new Zend_Http_Header_SetCookie('othername2', 'othervalue2');
     $headerLine = $setCookieHeader->toStringMultipleHeaders(array($appendCookie));
     $response = new Zend_Controller_Response_HttpTestCase();
     $response->setRawHeader($headerLine);
     $this->assertEquals((array) $headerLine, $response->sendHeaders());
 }