/** * Notify the browser to keeptrack lastest language use changing * * @param Zend_Locale | string $languageWantTranslateTo locale or language */ private function remember($languageWantTranslateTo) { // Notify browser set cookie 'lang', keep track lastest request language want translate $tenDayLastest = new DateTime("+10 days"); $cookieWriter = new Zend_Http_Header_SetCookie(); $cookieWriter->setName('lang')->setExpires($tenDayLastest->getTimestamp())->setValue((string) $languageWantTranslateTo)->setPath('/'); $this->getResponse()->setRawHeader($cookieWriter); }
/** * @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()); }