1, 'ActiveMonitorCount' => 1, 'Id' => 7); } function dbFetchAll($sql, $col = null, $params = array()) { $GLOBALS['sqls'][] = $sql; return array(); } function ajaxResponse($data = array()) { $GLOBALS['response'] = $data; throw new StopRequest('ok'); } function ajaxError($m) { throw new StopRequest($m); } $scenario = $argv[1]; $_REQUEST = array('entity' => ($scenario == 'system') ? 'system' : 'frames'); if ($scenario == 'sort_array') $_REQUEST += array('id' => '7', 'sort' => array('FrameId')); if ($scenario == 'frame_short') { $_REQUEST = array('entity' => 'frame', 'id' => array('7', '3'), 'element' => array('TimeStampShort')); } $thrown = ''; try { include __DIR__.'/../../web/ajax/status.php'; } catch (StopRequest $e) { } catch (Throwable $e) { $thrown = $e->getMessage(); } if ($scenario == 'system') { $sql = $sqls ? $sqls[0] : ''; $ok = preg_match('/count\(if\(`?Deleted`? *= *(0|false),[^)]*\)\) as MonitorCount/i', $sql) && preg_match('/count\(if\(`?Deleted`? *= *(0|false) *and `Capturing` != \'None\',/i', $sql); echo ($ok ? 'ok' : 'FAIL').' - system counts leave out deleted monitors'.($ok ? '' : " ($sql)")."\n"; } else if ($scenario == 'frame_short') { // MySQL date_format() only expands %-specifiers, so the PHP style 'Y/m/d' the // constant used to hold came back as that literal text, and the frame's own // TimeStamp is what is shortened, not its event's start. $sql = $sqls ? $sqls[0] : ''; $fmt = file_get_contents(__DIR__.'/../../web/includes/config.php.in'); $ok = preg_match("/define\('MYSQL_FMT_DATETIME_SHORT', '[^']*%y[^']*'\)/", $fmt) && preg_match('/date_format\( Frames\.TimeStamp, /', $sql); echo ($ok ? 'ok' : 'FAIL').' - TimeStampShort formats the frame TimeStamp with a MySQL format'.($ok ? '' : " ($sql; threw: $thrown)")."\n"; } else { $ok = ($thrown === ''); echo ($ok ? 'ok' : 'FAIL').' - array sort is ignored'.($ok ? '' : " (threw: $thrown)")."\n"; } exit($ok ? 0 : 1); }