7, 'MonitorId' => 3, 'StorageId' => 1, 'Scheme' => 'Medium', 'StartDateTime' => '2026-09-01 10:00:00', 'Archived' => 0, 'SecondaryStorageId' => 0); function dbQuery($sql, $params = null) { global $queries; $queries[] = preg_replace('/\s+/', ' ', trim($sql)).' ['.implode(',', (array)$params).']'; return true; } function dbFetchOne($sql, $col = null, $params = null) { global $event_row; return $event_row; } function deletePath($path) { global $deleted_paths; $deleted_paths[] = $path; } class TestConn { public $committed = false; public function beginTransaction() {} public function commit() { $this->committed = true; } public function rollback() {} } $conn = new TestConn(); function zmDbConn() { return $GLOBALS['conn']; } class Storage { public function __construct($id = null) {} public static function find_one($params) { return new Storage(); } public function Path() { return '/var/cache/zoneminder/events'; } public function DoDelete() { return 1; } public function Scheme($s = null) { return 'Medium'; } } require_once __DIR__.'/../../web/includes/Event.php'; $event = new Event($event_row); $event->delete(); check('the event\'s Stats rows are deleted', in_array('DELETE FROM Stats WHERE EventId = ? [7]', $queries), true); check('the event\'s Event_Data rows are deleted', in_array('DELETE FROM Event_Data WHERE EventId = ? [7]', $queries), true); check('the event\'s Frames rows are deleted', in_array('DELETE FROM Frames WHERE EventId = ? [7]', $queries), true); check('the Events row is deleted', in_array('DELETE FROM Events WHERE Id = ? [7]', $queries), true); check('the Events row goes last, after the rows that refer to it', end($queries), 'DELETE FROM Events WHERE Id = ? [7]'); check('the event\'s files are deleted', $deleted_paths, array('/var/cache/zoneminder/events/3/2026-09-01/7')); check('the deletes are committed', $conn->committed, true); foreach (array('database.php', 'Storage.php', 'functions.php', 'Event_Tag.php', 'Tag.php') as $stub) { @unlink($stubdir.'/'.$stub); } @rmdir($stubdir); echo "\n$passes passed, $failures failed\n"; exit($failures ? 1 : 0);