diff --git a/src/Illuminate/Routing/Redirector.php b/src/Illuminate/Routing/Redirector.php index c7e10001e7f1..362e288a3ecc 100755 --- a/src/Illuminate/Routing/Redirector.php +++ b/src/Illuminate/Routing/Redirector.php @@ -113,19 +113,6 @@ public function intended($default = '/', $status = 302, $headers = [], $secure = return $this->to($path, $status, $headers, $secure); } - /** - * Set the intended url. - * - * @param string $url - * @return $this - */ - public function setIntendedUrl($url) - { - $this->session->put('url.intended', $url); - - return $this; - } - /** * Create a new redirect response to the given path. * @@ -263,4 +250,27 @@ public function setSession(SessionStore $session) { $this->session = $session; } + + /** + * Get the "intended" URL from the session. + * + * @return string|null + */ + public function getIntendedUrl() + { + return $this->session->get('url.intended'); + } + + /** + * Set the "intended" URL in the session. + * + * @param string $url + * @return $this + */ + public function setIntendedUrl($url) + { + $this->session->put('url.intended', $url); + + return $this; + } } diff --git a/tests/Routing/RoutingRedirectorTest.php b/tests/Routing/RoutingRedirectorTest.php index 4e822aa59947..113cda343b34 100644 --- a/tests/Routing/RoutingRedirectorTest.php +++ b/tests/Routing/RoutingRedirectorTest.php @@ -178,11 +178,14 @@ public function testTemporarySignedRoute() $this->assertSame('http://foo.com/bar?signature=secret', $response->getTargetUrl()); } - public function testItSetsValidIntendedUrl() + public function testItSetsAndGetsValidIntendedUrl() { $this->session->shouldReceive('put')->once()->with('url.intended', 'http://foo.com/bar'); + $this->session->shouldReceive('get')->andReturn('http://foo.com/bar'); $result = $this->redirect->setIntendedUrl('http://foo.com/bar'); $this->assertInstanceOf(Redirector::class, $result); + + $this->assertSame('http://foo.com/bar', $this->redirect->getIntendedUrl()); } }