Source
xxxxxxxxxx
' a / {#B}{{#C}.regsub("^([0-9]+)", "{#C}: \1")} ~!@#$%^&*()[]{};:\'"|\\ \/', 0, ['lldmacros' => 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 CHostGroupNameParserTest extends TestCase {
/**
* An array of time periods and parsed results.
*/
public static function dataProvider() {
return [
// success
[
' ', 0, [],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => ' ',
'macros' => []
]
],
[
' a ', 0, [],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => ' a ',
'macros' => []
]
],
[
' abc{#ABC}def~!@#$%^&*()[]-_+={};:\'"?<>', 0, [],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => ' abc{#ABC}def~!@#$%^&*()[]-_+={};:\'"?<>',
'macros' => []
]
],
[
'/abc{#ABC}//def~!@#$%^&*()[]-_+={};:\'"?<>|\\', 12, [],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => 'def~!@#$%^&*()[]-_+={};:\'"?<>|\\',
'macros' => []
]
],
[
' a{#B}c ', 0, ['lldmacros' => true],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => ' a{#B}c ',
'macros' => ['{#B}']
]
],
[
' a{#B}c / {#D}e/f ', 0, ['lldmacros' => true],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => ' a{#B}c / {#D}e/f ',
'macros' => ['{#B}', '{#D}']
]
],
[
' a{#B}{{#C}.regsub("^([0-9]+)", "{#C}: \1")}{#D}/e ', 0, ['lldmacros' => true],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => ' a{#B}{{#C}.regsub("^([0-9]+)", "{#C}: \1")}{#D}/e ',
'macros' => ['{#B}', '{{#C}.regsub("^([0-9]+)", "{#C}: \1")}', '{#D}']
]
],
[
' a{#B}{{#C}.regsub("^([0-9]+\/[A-Za-z])", "{#C}: \1")}{#D}/e ', 0, ['lldmacros' => true],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => ' a{#B}{{#C}.regsub("^([0-9]+\/[A-Za-z])", "{#C}: \1")}{#D}/e ',
'macros' => ['{#B}', '{{#C}.regsub("^([0-9]+\/[A-Za-z])", "{#C}: \1")}', '{#D}']
]
],
[