File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
src/Symfony/Component/ExpressionLanguage/Tests Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Component \ExpressionLanguage \Tests ;
13
13
14
+ use Symfony \Component \ExpressionLanguage \ExpressionFunction ;
14
15
use PHPUnit \Framework \TestCase ;
15
16
use Symfony \Component \ExpressionLanguage \ExpressionLanguage ;
16
17
use Symfony \Component \ExpressionLanguage \Tests \Fixtures \TestProvider ;
@@ -139,4 +140,22 @@ public function testCachingWithDifferentNamesOrder()
139
140
$ expressionLanguage ->compile ($ expression , array ('a ' , 'B ' => 'b ' ));
140
141
$ expressionLanguage ->compile ($ expression , array ('B ' => 'b ' , 'a ' ));
141
142
}
143
+
144
+ public function testAddingFunctionAfterEval ()
145
+ {
146
+ $ el = new ExpressionLanguage ();
147
+ $ el ->evaluate ('1 + 1 ' );
148
+ $ el ->addFunction (new ExpressionFunction ('fn ' , function () {}, function () {}));
149
+ $ result = $ el ->evaluate ('fn() ' );
150
+ $ this ->assertNull ($ result );
151
+ }
152
+
153
+ public function testAddingFunctionAfterCompile ()
154
+ {
155
+ $ el = new ExpressionLanguage ();
156
+ $ el ->compile ('1 + 1 ' );
157
+ $ el ->addFunction (new ExpressionFunction ('fn ' , function () {}, function () {}));
158
+ $ result = $ el ->compile ('fn() ' );
159
+ $ this ->assertEmpty ($ result );
160
+ }
142
161
}
You can’t perform that action at this time.
0 commit comments