array('Name' => $name)); $user = new class { function Id() { return 1; } }; (function() use ($root) { global $action, $user, $redirect, $error_message; include $root.'/web/includes/actions/report.php'; })(); return array($saved, $error_message); } $fail = 0; function check($n, $ok) { global $fail; echo ($ok ? 'ok' : 'FAIL')." - $n\n"; if (!$ok) $fail++; } list($saved, $err) = attempt($root, ' '); check('blank name is not saved', $saved === null); check('blank name gives an error message', $err !== ''); list($saved, $err) = attempt($root, ' Front door '); check('padded name is saved trimmed', is_array($saved) && ($saved['Name'] ?? null) === 'Front door'); system('rm -rf '.escapeshellarg($stub)); exit($fail ? 1 : 0);