Beispiel #1
0
 /**
  * Tests, that the redirect function throws an exception and correctly
  * passes the parameters.
  */
 public function testRedirect()
 {
     $this->createCleanResponse();
     try {
         $this->response->redirect('http://www.example.com/', 301);
         $this->fail('HttpResponse::redirect should throw a RedirectException');
     } catch (\YapepBase\Exception\RedirectException $e) {
     }
     $this->response->send();
     $this->assertEquals(301, $this->output->responseCode);
     $this->assertEquals(array('http://www.example.com/'), $this->output->headers['Location']);
 }
 function testRedirectToRoute()
 {
     $previousLevel = ob_get_level();
     $router = new RouterMock();
     Application::getInstance()->setRouter($router);
     $request = new HttpRequest(array(), array(), array(), array('REQUEST_URI' => '/'), array(), array());
     $out = new OutputMock();
     $response = new HttpResponse($out);
     $o = new HttpMockController($request, $response);
     try {
         $o->testRedirectToRoute();
         $this->resetObToLevel($previousLevel);
         $this->fail('RedirectToRoute test should result in a RedirectException');
     } catch (RedirectException $e) {
         $this->assertEquals(RedirectException::TYPE_EXTERNAL, $e->getCode());
     }
     $response->send();
     $this->assertEquals(303, $out->responseCode);
     $this->assertEquals(array('/?test=test&test2%5B0%5D=test1&test2%5B1%5D=test2#test'), $out->headers['Location']);
     $this->resetObToLevel($previousLevel);
 }
 /**
  * Redirects the client to the specified URL.
  *
  * @param string $url          The URL to redirect to.
  * @param int    $statusCode   The status code of the redirect (3XX).
  *
  * @return void
  *
  * @throws \YapepBase\Exception\RedirectException   To stop execution of the controller.
  */
 protected function redirectToUrl($url, $statusCode = 303)
 {
     $this->response->redirect($url, $statusCode);
     // @codeCoverageIgnoreStart
 }
Beispiel #4
0
 /**
  * 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);
 }