clqms-be/tests/unit/Rules/RuleExpressionServiceTest.php

25 lines
588 B
PHP
Raw Normal View History

<?php
namespace Tests\Unit\Rules;
use App\Services\RuleExpressionService;
use CodeIgniter\Test\CIUnitTestCase;
class RuleExpressionServiceTest extends CIUnitTestCase
{
public function testEvaluateBooleanWithArrayContext(): void
{
$svc = new RuleExpressionService();
$ok = $svc->evaluateBoolean('order["SiteID"] == 1', [
'order' => ['SiteID' => 1],
]);
$this->assertTrue($ok);
$no = $svc->evaluateBoolean('order["SiteID"] == 2', [
'order' => ['SiteID' => 1],
]);
$this->assertFalse($no);
}
}