Skip to content

Commit f34e8e8

Browse files
test: add Pest unit tests for XML import payload helper
1 parent 8a7609b commit f34e8e8

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
// Stubs for Cacti core functions used in functions.php
6+
if (!function_exists('get_nfilter_request_var')) {
7+
function get_nfilter_request_var($name) { return $_POST[$name] ?? $_GET[$name] ?? ''; }
8+
}
9+
if (!function_exists('get_request_var')) {
10+
function get_request_var($name) { return $_POST[$name] ?? $_GET[$name] ?? ''; }
11+
}
12+
if (!function_exists('__')) { function __($str, $domain) { return $str; } }
13+
if (!function_exists('cacti_log')) { function cacti_log($msg, $stderr, $fac) {} }
14+
15+
require_once __DIR__ . '/../../functions.php';
16+
17+
test('syslog_get_import_xml_payload loads from text area', function () {
18+
$_POST['import_text'] = '<xml>test</xml>';
19+
$payload = syslog_get_import_xml_payload('http://localhost');
20+
expect($payload)->toBe('<xml>test</xml>');
21+
});

0 commit comments

Comments
 (0)