Skip to content

Commit 4002983

Browse files
committed
[SecurityBundle] Backport test
1 parent ccca259 commit 4002983

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ public function testHandleWhenUsernameLength($username, $ok)
7777
}
7878

7979
/**
80+
* @dataProvider postOnlyDataProvider
8081
* @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
8182
* @expectedExceptionMessage The key "_username" must be a string, "array" given.
8283
*/
83-
public function testHandleNonStringUsername()
84+
public function testHandleNonStringUsername($postOnly)
8485
{
8586
$request = Request::create('/login_check', 'POST', array('_username' => array()));
8687
$request->setSession($this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock());
87-
8888
$listener = new UsernamePasswordFormAuthenticationListener(
8989
new TokenStorage(),
9090
$this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(),
@@ -93,14 +93,20 @@ public function testHandleNonStringUsername()
9393
'foo',
9494
new DefaultAuthenticationSuccessHandler($httpUtils),
9595
new DefaultAuthenticationFailureHandler($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $httpUtils),
96-
array('require_previous_session' => false)
96+
array('require_previous_session' => false, 'post_only' => $postOnly)
9797
);
98-
9998
$event = new GetResponseEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST);
100-
10199
$listener->handle($event);
102100
}
103101

102+
public function postOnlyDataProvider()
103+
{
104+
return array(
105+
array(true),
106+
array(false),
107+
);
108+
}
109+
104110
public function getUsernameForLength()
105111
{
106112
return array(

0 commit comments

Comments
 (0)