Skip to content

Commit f387b69

Browse files
Update IsAnonymousTest for Symfony 6.x PUBLIC_ACCESS change
1 parent 58a692c commit f387b69

2 files changed

Lines changed: 3 additions & 8 deletions

File tree

src/Security/Security.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ public function hasRole(string $role): bool
104104

105105
public function isAnonymous(): bool
106106
{
107-
// IS_AUTHENTICATED_ANONYMOUSLY was removed from AuthenticatedVoter in Symfony 6.x.
108-
// PUBLIC_ACCESS (added in Symfony 5.4) is the correct replacement and always grants access.
109-
return $this->isGranted(Kernel::VERSION_ID >= 60000 ? 'PUBLIC_ACCESS' : 'IS_AUTHENTICATED_ANONYMOUSLY');
107+
return $this->isGranted('PUBLIC_ACCESS');
110108
}
111109

112110
public function isAuthenticated(): bool

tests/ExpressionLanguage/ExpressionFunction/Security/IsAnonymousTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ protected function getFunctions()
1717

1818
public function testEvaluator(): void
1919
{
20-
$security = $this->getSecurityIsGrantedWithExpectation(
21-
'IS_AUTHENTICATED_ANONYMOUSLY',
22-
$this->any()
23-
);
20+
$security = $this->getSecurityIsGrantedWithExpectation('PUBLIC_ACCESS', $this->any());
2421
$services = $this->createGraphQLServices(['security' => $security]);
2522

2623
$isAnonymous = $this->expressionLanguage->evaluate('isAnonymous()', [TypeGenerator::GRAPHQL_SERVICES => $services]);
@@ -29,6 +26,6 @@ public function testEvaluator(): void
2926

3027
public function testIsAnonymous(): void
3128
{
32-
$this->assertExpressionCompile('isAnonymous()', 'IS_AUTHENTICATED_ANONYMOUSLY');
29+
$this->assertExpressionCompile('isAnonymous()', 'PUBLIC_ACCESS');
3330
}
3431
}

0 commit comments

Comments
 (0)