/** * Tests the correct handling of cookies. */ public function testCookies() { $this->createCleanResponse(); $data = array('name' => 'testcookie', 'value' => 'testvalue', 'expire' => 3600, 'path' => '/test', 'domain' => 'www.example.com', 'secure' => true, 'httponly' => true); $this->assertEquals(array(), $this->output->cookies, 'The cookies array is not empty in OutputMock. Possibly a bug in HttpResponseTest::createCleanResponse?'); $this->assertEquals(false, $this->response->hasCookie($data['name'])); $this->response->setCookie($data['name'], $data['value'], $data['expire'], $data['path'], $data['domain'], $data['secure'], $data['httponly']); $this->assertEquals(true, $this->response->hasCookie($data['name'])); $this->response->send(); $this->assertEquals(array($data['name'] => $data), $this->output->cookies); $this->createCleanResponse(); $data = array('name' => 'testcookie', 'value' => 'testvalue', 'expire' => 3600, 'path' => '/test', 'domain' => 'www.example.org', 'secure' => true, 'httponly' => true); Config::getInstance()->set('system.response.defaultCookieDomain', $data['domain']); $this->response->setCookie($data['name'], $data['value'], $data['expire'], $data['path'], null, $data['secure'], $data['httponly']); $this->response->send(); $this->assertEquals(array($data['name'] => $data), $this->output->cookies); }
/** * Destroys the session. * * @return void * * @see YapepBase\Session.SessionAbstract::destroy() */ public function destroy() { parent::destroy(); $this->response->setCookie($this->cookieName, '', 1, $this->cookiePath, $this->cookieDomain); }