Source
<?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/>.
**/
/**
* Class containing methods to test CIPRangeParser class functionality.
*/
use PHPUnit\Framework\TestCase;
class CIPRangeParserTest extends TestCase {
public function dataProvider() {
return [
[
'{$MACRO}', ['usermacros' => true], [
'rc' => true,
'error' => '',
'max_ip_count' => '0',
'max_ip_range' => ''
]
],
[
'{{$M}.regsub("^([0-9]+)", \1)}', ['usermacros' => true], [
'rc' => true,
'error' => '',
'max_ip_count' => '0',
'max_ip_range' => ''
]
],
[
"0.0.0.0,255.255.255.255 \t\r\n,\t\r\n 192.168.1.0,2002:0:0:0:0:0:0:0,2002:0:0:0:0:0:ffff:ffff,www.zabbix.com", [], [
'rc' => true,
'error' => '',
'max_ip_count' => '1',
'max_ip_range' => '0.0.0.0'
]
],
[
'www.zabbix.com', [], [
'rc' => true,
'error' => '',
'max_ip_count' => '1',
'max_ip_range' => 'www.zabbix.com'
]
],
[
'www.zabbix.com,bad.dns-', [], [
'rc' => true,
'error' => '',
'max_ip_count' => '1',
'max_ip_range' => 'www.zabbix.com'