$ids); $GLOBALS['action'] = 'delete'; $GLOBALS['failing'] = $failing; $GLOBALS['deletes'] = array(); $GLOBALS['rebuilt'] = false; $action = 'delete'; $redirect = null; include $root.'/web/includes/actions/cron.php'; return array($cron_error, $redirect); }; list($err, $redirect) = $run(array('3', '4'), array()); $check('a good delete reports no error', $err === ''); $check('a good delete rebuilds the crontab', $GLOBALS['rebuilt'] === true); $check('a good delete returns to the list', $redirect === '?view=cron'); list($err, $redirect) = $run(array('3', '4'), array(4)); $check('a failed delete is reported', strpos($err, 'Unable to delete scheduled task 4') !== false); $check('the database error is included', strpos($err, 'db down') !== false); $check('a failed delete shows the error on the page', strpos((string)$redirect, 'error=') !== false); $check('the other task is still deleted', $GLOBALS['deletes'] === array(3, 4)); $check('the crontab is still rebuilt for the task that was deleted', $GLOBALS['rebuilt'] === true); foreach (array('CronJob', 'CronTab', 'Command') as $f) unlink($dir.'/includes/'.$f.'.php'); rmdir($dir.'/includes'); chdir('/'); rmdir($dir); echo $fail ? "$fail failed\n" : "all passed\n"; exit($fail ? 1 : 0); }