File tree Expand file tree Collapse file tree 2 files changed +19
-12
lines changed
src/ExpressionLanguage/ExpressionFunction/Security
tests/ExpressionLanguage/ExpressionFunction/Security Expand file tree Collapse file tree 2 files changed +19
-12
lines changed Original file line number Diff line number Diff line change 55namespace Overblog \GraphQLBundle \ExpressionLanguage \ExpressionFunction \Security ;
66
77use Overblog \GraphQLBundle \ExpressionLanguage \ExpressionFunction ;
8- use Overblog \GraphQLBundle \Security \Security ;
98
109final class IsAuthenticated extends ExpressionFunction
1110{
12- public function __construct (Security $ security )
11+ public function __construct ()
1312 {
1413 parent ::__construct (
1514 'isAuthenticated ' ,
1615 static function (): string {
1716 return '$globalVariable->get( \'security \')->isAuthenticated() ' ;
1817 },
19- static function () use ( $ security ): bool {
20- return $ security ->isAuthenticated ();
18+ static function ($ arguments ): bool {
19+ return $ arguments [ ' globalVariable ' ]-> get ( ' security ' ) ->isAuthenticated ();
2120 }
2221 );
2322 }
Original file line number Diff line number Diff line change 44
55namespace Overblog \GraphQLBundle \Tests \ExpressionLanguage \ExpressionFunction \Security ;
66
7+ use Overblog \GraphQLBundle \Definition \GlobalVariables ;
78use Overblog \GraphQLBundle \ExpressionLanguage \ExpressionFunction \Security \IsAuthenticated ;
89use Overblog \GraphQLBundle \Tests \ExpressionLanguage \TestCase ;
910
1011class IsAuthenticatedTest extends TestCase
1112{
1213 protected function getFunctions ()
1314 {
14- $ Security = $ this ->getSecurityIsGrantedWithExpectation (
15- $ this ->matchesRegularExpression ('/^IS_AUTHENTICATED_(REMEMBERED|FULLY)$/ ' ),
16- $ this ->any ()
17- );
18-
19- return [new IsAuthenticated ($ Security )];
15+ return [new IsAuthenticated ()];
2016 }
2117
2218 public function testEvaluator (): void
2319 {
24- $ isAuthenticated = $ this ->expressionLanguage ->evaluate ('isAuthenticated() ' );
20+ $ security = $ this ->getSecurityIsGrantedWithExpectation (
21+ $ this ->matchesRegularExpression ('/^IS_AUTHENTICATED_(REMEMBERED|FULLY)$/ ' ),
22+ $ this ->any ()
23+ );
24+ $ globalVariable = new GlobalVariables (['security ' => $ security ]);
25+
26+ $ isAuthenticated = $ this ->expressionLanguage ->evaluate (
27+ 'isAuthenticated() ' ,
28+ ['globalVariable ' => $ globalVariable ]
29+ );
2530 $ this ->assertTrue ($ isAuthenticated );
2631 }
2732
2833 public function testIsAuthenticated (): void
2934 {
30- $ this ->assertExpressionCompile ('isAuthenticated() ' , $ this ->matchesRegularExpression ('/^IS_AUTHENTICATED_(REMEMBERED|FULLY)$/ ' ));
35+ $ this ->assertExpressionCompile (
36+ 'isAuthenticated() ' ,
37+ $ this ->matchesRegularExpression ('/^IS_AUTHENTICATED_(REMEMBERED|FULLY)$/ ' )
38+ );
3139 }
3240}
You can’t perform that action at this time.
0 commit comments