8000 Add tests · symfony/symfony@d1d949f · GitHub
[go: up one dir, main page]

Skip to content

Commit d1d949f

Browse files
committed
Add tests
1 parent 7a5d047 commit d1d949f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\ExpressionLanguage\Tests;
1313

14+
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
1617
use Symfony\Component\ExpressionLanguage\Tests\Fixtures\TestProvider;
@@ -139,4 +140,22 @@ public function testCachingWithDifferentNamesOrder()
139140
$expressionLanguage->compile($expression, array('a', 'B' => 'b'));
140141
$expressionLanguage->compile($expression, array('B' => 'b', 'a'));
141142
}
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+
}
142161
}

0 commit comments

Comments
 (0)
0