summaryrefslogtreecommitdiffstats
path: root/Http/Tests/Authentication
diff options
context:
space:
mode:
Diffstat (limited to 'Http/Tests/Authentication')
-rw-r--r--Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php34
-rw-r--r--Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php14
2 files changed, 35 insertions, 13 deletions
diff --git a/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php b/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php
index 252b124..c97ee69 100644
--- a/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php
+++ b/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php
@@ -18,17 +18,12 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
class DefaultAuthenticationFailureHandlerTest extends \PHPUnit_Framework_TestCase
{
- private $httpKernel = null;
-
- private $httpUtils = null;
-
- private $logger = null;
-
- private $request = null;
-
- private $session = null;
-
- private $exception = null;
+ private $httpKernel;
+ private $httpUtils;
+ private $logger;
+ private $request;
+ private $session;
+ private $exception;
protected function setUp()
{
@@ -146,7 +141,7 @@ class DefaultAuthenticationFailureHandlerTest extends \PHPUnit_Framework_TestCas
public function testFailurePathCanBeOverwrittenWithRequest()
{
$this->request->expects($this->once())
- ->method('get')->with('_failure_path', null, true)
+ ->method('get')->with('_failure_path')
->will($this->returnValue('/auth/login'));
$this->httpUtils->expects($this->once())
@@ -156,12 +151,25 @@ class DefaultAuthenticationFailureHandlerTest extends \PHPUnit_Framework_TestCas
$handler->onAuthenticationFailure($this->request, $this->exception);
}
+ public function testFailurePathCanBeOverwrittenWithNestedAttributeInRequest()
+ {
+ $this->request->expects($this->once())
+ ->method('get')->with('_failure_path')
+ ->will($this->returnValue(array('value' => '/auth/login')));
+
+ $this->httpUtils->expects($this->once())
+ ->method('createRedirectResponse')->with($this->request, '/auth/login');
+
+ $handler = new DefaultAuthenticationFailureHandler($this->httpKernel, $this->httpUtils, array('failure_path_parameter' => '_failure_path[value]'), $this->logger);
+ $handler->onAuthenticationFailure($this->request, $this->exception);
+ }
+
public function testFailurePathParameterCanBeOverwritten()
{
$options = array('failure_path_parameter' => '_my_failure_path');
$this->request->expects($this->once())
- ->method('get')->with('_my_failure_path', null, true)
+ ->method('get')->with('_my_failure_path')
->will($this->returnValue('/auth/login'));
$this->httpUtils->expects($this->once())
diff --git a/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php b/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php
index ae9f02b..5372993 100644
--- a/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php
+++ b/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php
@@ -69,6 +69,20 @@ class DefaultAuthenticationSuccessHandlerTest extends \PHPUnit_Framework_TestCas
$this->assertSame($response, $result);
}
+ public function testTargetPathIsPassedAsNestedParameterWithRequest()
+ {
+ $this->request->expects($this->once())
+ ->method('get')->with('_target_path')
+ ->will($this->returnValue(array('value' => '/dashboard')));
+
+ $response = $this->expectRedirectResponse('/dashboard');
+
+ $handler = new DefaultAuthenticationSuccessHandler($this->httpUtils, array('target_path_parameter' => '_target_path[value]'));
+ $result = $handler->onAuthenticationSuccess($this->request, $this->token);
+
+ $this->assertSame($response, $result);
+ }
+
public function testTargetPathParameterIsCustomised()
{
$options = array('target_path_parameter' => '_my_target_path');