Source
<?php declare(strict_types = 0);
/*
** 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.
**/
/**
* 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' => ''
]
],
[
"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'
]
],
[
'0.0.0.0/0', [], [
'rc' => true,
'error' => '',
'max_ip_count' => '4294967296',
'max_ip_range' => '0.0.0.0/0'
]
],
[
'0.0.0.0/30', [], [
'rc' => true,
'error' => '',
'max_ip_count' => '4',
'max_ip_range' => '0.0.0.0/30'
]
],
[
'192.168.255.0/30', [], [
'rc' => true,
'error' => '',
'max_ip_count' => '4',
'max_ip_range' => '192.168.255.0/30'
]
],
[
'192.168.0-255.0-255', [], [
'rc' => true,
'error' => '',
'max_ip_count' => '65536',