Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9d45d95

Browse filesBrowse files
committed
minor #53587 [Security] fix tests (xabbuh)
This PR was merged into the 5.4 branch. Discussion ---------- [Security] fix tests | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT spotted while merging #53509 up where we added return types to the `AuthenticationUtils` methods Commits ------- c78f3e1 fix tests
2 parents 1c7c730 + c78f3e1 commit 9d45d95
Copy full SHA for 9d45d95

File tree

1 file changed

+12
-6
lines changed
Filter options

1 file changed

+12
-6
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Tests/Authentication/AuthenticationUtilsTest.php
+12-6Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,52 +16,58 @@
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\Exception\AuthenticationException;
1920
use Symfony\Component\Security\Core\Security;
2021
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
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(Security::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(Security::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());
52+
$this->assertSame($authenticationError, $utils->getLastAuthenticationError());
4953
$this->assertFalse($session->has(Security::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(Security::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));
70+
$this->assertSame($authenticationError, $utils->getLastAuthenticationError(false));
6571
$this->assertTrue($session->has(Security::AUTHENTICATION_ERROR));
6672
}
6773

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.