public function testBackRedirectShouldHasRootLocationIfRefererFromAnotherDomain() { $_SERVER['HTTP_REFERER'] = 'http://example.com/foo'; unset($_SERVER['HTTP_HOST']); $this->redirect->back(); self::assertEquals('/', $this->getResponse()->getHeader('Location')); self::assertEquals(302, $this->getResponse()->getStatus()); }
/** * @return \Nano\Controller\Redirect * @param null|string $to * @param int $status */ public function redirect($to = null, $status = 302) { if (null === $this->redirect) { $this->redirect = new \Nano\Controller\Redirect($this->response()); } $this->markRendered(); if (null === $to) { return $this->redirect; } $this->redirect->to($to, $status); return $this->redirect; }