Source
<?php
/*
** 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/>.
**/
require_once dirname(__FILE__).'/../include/CAPITest.php';
/**
* @onBefore prepareTestData
*
* @backup hstgrp
*/
class testHostGroup extends CAPITest {
public static function hostgroup_create() {
return [
[
'hostgroup' => [
'name' => 'non existent parameter',
'flags' => '4'
],
'expected_error' => 'Invalid parameter "/1": unexpected parameter "flags".'
],
// Check hostgroup name.
[
'hostgroup' => [
'name' => ''
],
'expected_error' => 'Invalid parameter "/1/name": cannot be empty.'
],
[
'hostgroup' => [
'name' => 'Phasellus imperdiet sapien sed justo elementum, quis maximus ipsum iaculis! Proin egestas, felis non efficitur molestie, nulla risus facilisis nisi, sed consectetur lorem mauris non arcu. Aliquam hendrerit massa vel metus maximus consequat. Sed condimen256'
],
'expected_error' => 'Invalid parameter "/1/name": value is too long.'
],
// Check for duplicated host groups names.
[
'hostgroup' => [
'name' => 'Zabbix servers'
],
'expected_error' => 'Host group "Zabbix servers" already exists.'
],
[
'hostgroup' => [
[
'name' => 'One host group with existing name'
],
[
'name' => 'Zabbix servers'
]
],