Source
['/Zabbix server/logrt["/home/zabbix32/test[0-9].log",ERROR,,1000,,,120.0]?[{$MACRO} = {{#MACRO}.func()} and group = "group"]', 0, ['usermacros' => true, 'lldmacros' => true, 'calculated' => true], [
<?php declare(strict_types = 0);
/*
** 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 Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
use PHPUnit\Framework\TestCase;
class CQueryParserTest extends TestCase {
public function dataProvider() {
return [
['/Zabbix server/logrt["/home/zabbix32/test[0-9].log",ERROR,,1000,,,120.0]', 0, [], [
'rc' => CParser::PARSE_SUCCESS,
'match' => '/Zabbix server/logrt["/home/zabbix32/test[0-9].log",ERROR,,1000,,,120.0]',
'host' => 'Zabbix server',
'item' => 'logrt["/home/zabbix32/test[0-9].log",ERROR,,1000,,,120.0]',
'filter' => [
'match' => '',
'tokens' => []
]
]],
['/h/i', 0, [], [
'rc' => CParser::PARSE_SUCCESS,
'match' => '/h/i',
'host' => 'h',
'item' => 'i',
'filter' => [
'match' => '',
'tokens' => []
]
]],
['text /h/i text', 5, [], [
'rc' => CParser::PARSE_SUCCESS_CONT,
'match' => '/h/i',
'host' => 'h',
'item' => 'i',
'filter' => [
'match' => '',
'tokens' => []
]
]],
['text /{HOST.HOST}/item[pam, "param"] text', 5, [], [
'rc' => CParser::PARSE_FAIL,
'match' => '',
'host' => '',
'item' => '',
'filter' => [
'match' => '',
'tokens' => []
]
]],
['text /{HOST.HOST1}/item[pam, "param"] text', 5, ['host_macro' => true], [