8000 Merge branch '6.3' into 6.4 · symfony/symfony@dd5902c · GitHub
[go: up one dir, main page]

Skip to content

Commit dd5902c

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: fix used class after merge fix tests
2 parents a09b0f2 + 5f069d2 commit dd5902c

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

src/Symfony/Component/Security/Http/Tests/Authentication/AuthenticationUtilsTest.php

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,59 +16,65 @@
1616
use Symfony\Component\HttpFoundation\RequestStack;
1717
use Symfony\Component\HttpFoundation\Session\Session;
1818
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
19-
use Symfony\Component\Security\Core\Security;
19+
use Symfony\Component\Security\Core\Exception\AuthenticationException;
2020
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
21+
use Symfony\Component\Security\Http\SecurityRequestAttributes;
2122

2223
class AuthenticationUtilsTest extends TestCase
2324
{
2425
public function testLastAuthenticationErrorWhenRequestHasAttribute()
2526
{
27+
$authenticationError = new AuthenticationException();
2628
$request = Request::create('/');
27-
$request->attributes->set(Security::AUTHENTICATION_ERROR, 'my error');
29+
$request->attributes->set(SecurityRequestAttributes::AUTHENTICATION_ERROR, $authenticationError);
2830

2931
$requestStack = new RequestStack();
3032
$requestStack->push($request);
3133

3234
$utils = new AuthenticationUtils($requestStack);
33-
$this->assertSame('my error', $utils->getLastAuthenticationError());
35+
$this->assertSame($authenticationError, $utils->getLastAuthenticationError());
3436
}
3537

3638
public function testLastAuthenticationErrorInSession()
3739
{
40+
$authenticationError = new AuthenticationException();
41+
3842
$request = Request::create('/');
3943

4044
$session = new Session(new MockArraySessionStorage());
41-
$session->set(Security::AUTHENTICATION_ERROR, 'session error');
45+
$session->set(SecurityRequestAttributes::AUTHENTICATION_ERROR, $authenticationError);
4246
$request->setSession($session);
4347

4448
$requestStack = new RequestStack();
4549
$requestStack->push($request);
4650

4751
$utils = new AuthenticationUtils($requestStack);
48-
$this->assertSame('session error', $utils->getLastAuthenticationError());
49-
$this->assertFalse($session->has(Security::AUTHENTICATION_ERROR));
52+
$this->assertSame($authenticationError, $utils->getLastAuthenticationError());
53+
$this->assertFalse($session->has(SecurityRequestAttributes::AUTHENTICATION_ERROR));
5054
}
5155

5256
public function testLastAuthenticationErrorInSessionWithoutClearing()
5357
{
58+
$authenticationError = new AuthenticationException();
59+
5460
$request = Request::create('/');
5561

5662
$session = new Session(new MockArraySessionStorage());
57-
$session->set(Security::AUTHENTICATION_ERROR, 'session error');
63+
$session->set(SecurityRequestAttributes::AUTHENTICATION_ERROR, $authenticationError);
5864
$request->setSession($session);
5965

6066
$requestStack = new RequestStack();
6167
$requestStack->push($request);
6268

6369
$utils = new AuthenticationUtils($requestStack);
64-
$this->assertSame('session error', $utils->getLastAuthenticationError(false));
65-
$this->assertTrue($session->has(Security::AUTHENTICATION_ERROR));
70+
$this->assertSame($authenticationError, $utils->getLastAuthenticationError(false));
71+
$this->assertTrue($session->has(SecurityRequestAttributes::AUTHENTICATION_ERROR));
6672
}
6773

6874
public function testLastUserNameIsDefinedButNull()
6975
{
7076
$request = Request::create('/');
71-
$request->attributes->set(Security::LAST_USERNAME, null);
77+
$request->attributes->set(SecurityRequestAttributes::LAST_USERNAME, null);
7278

7379
$requestStack = new RequestStack();
7480
$requestStack->push($request);
@@ -80,7 +86,7 @@ public function testLastUserNameIsDefinedButNull()
8086
public function testLastUserNameIsDefined()
8187
{
8288
$request = Request::create('/');
83-
$request->attributes->set(Security::LAST_USERNAME, 'user');
89+
$request->attributes->set(SecurityRequestAttributes::LAST_USERNAME, 'user');
8490

8591
$requestStack = new RequestStack();
8692
$requestStack->push($request);
@@ -94,7 +100,7 @@ public function testLastUserNameIsDefinedInSessionButNull()
94100
$request = Request::create('/');
95101

96102
$session = new Session(new MockArraySessionStorage());
97-
$session->set(Security::LAST_USERNAME, null);
103+
$session->set(SecurityRequestAttributes::LAST_USERNAME, null);
98104
$request->setSession($session);
99105

100106
$requestStack = new RequestStack();
@@ -109,7 +115,7 @@ public function testLastUserNameIsDefinedInSession()
109115
$request = Request::create('/');
110116

111117
$session = new Session(new MockArraySessionStorage());
112-
$session->set(Security::LAST_USERNAME, 'user');
118+
$session->set(SecurityRequestAttributes::LAST_USERNAME, 'user');
113119
$request->setSession($session);
114120

115121
$requestStack = new RequestStack();

0 commit comments

Comments
 (0)
0