'MonitorId', 'op'=>'=', 'val'=>'1'); $fail = 0; foreach (array( array('current time', array($monitor, array('cnj'=>'and', 'attr'=>'CurrentTime', 'op'=>'>=', 'val'=>'08:00'), array('cnj'=>'and', 'attr'=>'CurrentTime', 'op'=>'<=', 'val'=>'18:00')), 'MonitorId CurrentTime CurrentTime', '', ''), array('current datetime', array($monitor, array('cnj'=>'and', 'attr'=>'CurrentDateTime', 'op'=>'>=', 'val'=>'2026-12-01 00:00:00')), 'MonitorId CurrentDateTime', '', ''), array('current date', array($monitor, array('cnj'=>'and', 'attr'=>'CurrentDate', 'op'=>'<=', 'val'=>'2026-01-01')), 'MonitorId CurrentDate', '', ''), array('current weekday', array($monitor, array('cnj'=>'and', 'attr'=>'CurrentWeekday', 'op'=>'<', 'val'=>'5')), 'MonitorId CurrentWeekday', '', ''), array('start date time still bounds the window', array($monitor, array('cnj'=>'and', 'attr'=>'StartDateTime', 'op'=>'>=', 'val'=>'2024-03-04 00:00:00'), array('cnj'=>'and', 'attr'=>'CurrentTime', 'op'=>'>=', 'val'=>'08:00')), 'MonitorId CurrentTime', '2024-03-04 00:00:00', ''), ) as $case) { list($name, $terms, $wantAttrs, $wantMin, $wantMax) = $case; $filter = new ZM\Filter(); $filter->Query(array('terms'=>$terms)); $tree = $filter->tree(); $minTime = $maxTime = $expandable = false; extractDatetimeRange($tree, $minTime, $maxTime, $expandable); $attrs = array(); foreach (parseTreeToFilter($tree)['Query']['terms'] as $term) { if (isset($term['attr'])) $attrs[] = $term['attr']; } $attrs = implode(' ', $attrs); $ok = ($attrs === $wantAttrs && $minTime === $wantMin && $maxTime === $wantMax); echo ($ok ? 'ok ' : 'FAIL ')."$name: terms '$attrs', window '$minTime' .. '$maxTime'\n"; if (!$ok) $fail++; } @unlink($stubdir.'/database.php'); @unlink($stubdir.'/Monitor.php'); @rmdir($stubdir); exit($fail ? 1 : 0); }