Source
'last(/host/key, #25, "abc" ,"\"def\"", 1, 1.125, -1e12, {$M} , {$M: context}, {#M}, {{#M}.regsub()},, ,)', 0, ['usermacros' => true, 'lldmacros' => true],
<?php
/*
** Zabbix
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
use PHPUnit\Framework\TestCase;
class CHistFunctionParserTest extends TestCase {
/**
* An array of trigger functions and parsed results.
*/
public static function dataProvider() {
return [
[
'last(/host/key)', 0, [],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => 'last(/host/key)',
'function' => 'last',
'parameters' => [
[
'type' => CHistFunctionParser::PARAM_TYPE_QUERY,
'pos' => 5,
'match' => '/host/key',
'length' => 9,
'data' => [
'host' => 'host',
'item' => 'key',
'filter' => [
'match' => '',
'tokens' => []
]
]
]
]
],
['/host/key']
],
[
'last(/{HOST.HOST}/key)', 0, ['host_macro' => true],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => 'last(/{HOST.HOST}/key)',
'function' => 'last',
'parameters' => [
[
'type' => CHistFunctionParser::PARAM_TYPE_QUERY,
'pos' => 5,
'match' => '/{HOST.HOST}/key',
'length' => 16,
'data' => [
'host' => '{HOST.HOST}',
'item' => 'key',
'filter' => [
'match' => '',
'tokens' => []
]
]
]
]
],
['/{HOST.HOST}/key']
],
[
'last(/{HOST.HOST}/key)', 0, ['host_macro_n' => true],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => 'last(/{HOST.HOST}/key)',
'function' => 'last',
'parameters' => [
[
'type' => CHistFunctionParser::PARAM_TYPE_QUERY,
'pos' => 5,
'match' => '/{HOST.HOST}/key',