-
Notifications
You must be signed in to change notification settings - Fork 243
Expand file tree
/
Copy pathFormalExpressionTest.php
More file actions
44 lines (36 loc) · 1.33 KB
/
FormalExpressionTest.php
File metadata and controls
44 lines (36 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace Tests\Model;
use ProcessMaker\Exception\ScriptLanguageNotSupported;
use ProcessMaker\Models\FormalExpression;
use Tests\TestCase;
class FormalExpressionTest extends TestCase
{
public function testEvaluateSimpleExpression()
{
$formalExp = new FormalExpression();
$formalExp->setLanguage('FEEL');
$formalExp->setBody('condition == "passed"');
$eval = $formalExp(['condition' => 'test']);
$this->assertFalse($eval);
$eval = $formalExp(['condition' => 'passed']);
$this->assertTrue($eval);
}
public function testLanguageNotSupported()
{
$this->expectException(ScriptLanguageNotSupported::class);
$formalExp = new FormalExpression();
$formalExp->setLanguage('FEEL-X');
$formalExp->setBody('condition == "passed"');
$eval = $formalExp(['condition' => 'test']);
}
public function testEvaluateExpressionWithMustache()
{
$formalExp = new FormalExpression();
$formalExp->setLanguage('FEEL');
$formalExp->setBody('{{{expression}}}');
$eval = $formalExp(['expression' => 'condition == "passed"', 'condition' => 'test']);
$this->assertFalse($eval);
$eval = $formalExp(['expression' => "condition == 'passed'", 'condition' => 'passed']);
$this->assertTrue($eval);
}
}