mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-11-30 04:04:03 -05:00
* test: PHP test stubs know the helpers and include path merged code now uses Twenty tests in tests/php failed on master after PRs that each passed on their own landed together: code under test started calling a helper, or loading a file, that these tests' stand-ins didn't provide. - validCardinal(): actions/group.php, actions/controlcap.php and ajax/reports.php deleteRequest() reduce request ids with it (#7800). The five group save tests, the controlcap test and the reports delete test now carry a copy of it. - ZM\scalar_values_differ(): Object.php changes() compares with it (#7774). The group, storage, user and zmtrack tests that load Object.php now carry a copy. - authHashTtl(): generateAuthHash() takes its freshness limit from it (#8367). test_auth_hash_slot_age lifts it out of auth.php alongside generateAuthHash(). - includes/log_redact.php: ajax/status.php requires it relative to web/ (#7930). The five status tests put web/ on the include path before including status.php, as the web server's working directory does. - test_reports_ajax_forged_id: deleteRequest() now reports a delete() that returns false (#7820), and the stub Report::delete() returned nothing, so it returns true. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: filter text test lifts filterSelectionScalars() with getFilterSelection() getFilterSelection() in _monitor_filters.php now passes request and cookie values through filterSelectionScalars() (#8455), so the test has to evaluate that function too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
65 lines
1.8 KiB
PHP
65 lines
1.8 KiB
PHP
<?php
|
|
// A Group Name with non-ASCII letters must not be stripped by the input
|
|
// filter, while punctuation outside the allowed set still is.
|
|
//
|
|
// Run as: php tests/php/test_group_name_unicode.php [group_include_dir]
|
|
|
|
namespace ZM;
|
|
|
|
$failures = 0;
|
|
function check($name, $got, $want) {
|
|
global $failures;
|
|
if ($got === $want) {
|
|
echo "ok - $name\n";
|
|
} else {
|
|
$failures++;
|
|
echo "FAIL - $name (got ".var_export($got, true).", want ".var_export($want, true).")\n";
|
|
}
|
|
}
|
|
|
|
$stubdir = sys_get_temp_dir().'/zm_group_unicode_stubs_'.getmypid();
|
|
@mkdir($stubdir, 0700, true);
|
|
foreach (array('database.php') as $stub) {
|
|
file_put_contents($stubdir.'/'.$stub, "<?php\n");
|
|
}
|
|
|
|
$group_override = isset($argv[1]) ? $argv[1] : null;
|
|
$include = $stubdir.PATH_SEPARATOR;
|
|
if ($group_override) {
|
|
$include .= $group_override.PATH_SEPARATOR;
|
|
}
|
|
$include .= __DIR__.'/../../web/includes'.PATH_SEPARATOR.get_include_path();
|
|
set_include_path($include);
|
|
|
|
function Warning($s) {}
|
|
function Error($s) {}
|
|
function Debug($s) {}
|
|
// Copied from web/includes/functions.php; Object.php changes() calls it.
|
|
function scalar_values_differ($old, $new) {
|
|
if (is_array($old) or is_array($new)) {
|
|
return $old != $new;
|
|
}
|
|
if (is_bool($old)) $old = (int)$old;
|
|
if (is_bool($new)) $new = (int)$new;
|
|
return (string)($old === null ? '' : $old) !== (string)($new === null ? '' : $new);
|
|
}
|
|
|
|
require_once 'Object.php';
|
|
require_once 'Group.php';
|
|
|
|
$g = new Group();
|
|
$g->set($g->changes(array('Name' => "Café")));
|
|
check('accented name kept', $g->Name(), "Café");
|
|
|
|
$g = new Group();
|
|
$g->set($g->changes(array('Name' => "カメラ")));
|
|
check('japanese name kept', $g->Name(), "カメラ");
|
|
|
|
$g = new Group();
|
|
$g->set($g->changes(array('Name' => "a<b>")));
|
|
check('disallowed punctuation stripped', $g->Name(), "ab");
|
|
|
|
array_map('unlink', glob($stubdir.'/*'));
|
|
rmdir($stubdir);
|
|
exit($failures ? 1 : 0);
|