Source
'expected_error' => 'Cannot delete hosts "api_test_hosts_maintenance_5", "api_test_hosts_maintenance_6" because maintenance "API test hosts - maintenance with two hosts (non-deletable)" must contain at least one host or host group.'
<?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 __DIR__.'/../include/CAPITest.php';
require_once __DIR__.'/../include/helpers/CTestDataHelper.php';
/**
* @onBefore prepareHostsData
*
* @onAfter clearData
*
* @backup hosts
*/
class testHost extends CAPITest {
private static $data = [
'hostgroupid' => null,
'hostids' => [
// Test host.delete if hosts are in maintenance.
'maintenance_1' => null,
'maintenance_2' => null,
'maintenance_3' => null,
'maintenance_4' => null,
'maintenance_5' => null,
'maintenance_6' => null,
'maintenance_7' => null,
// Test host.get with tags.
'tags' => null,
// Test host.get with write-only fields.
'write_only' => null,
// Host with LLD rule and host prototype.
'with_lld_and_prototype' => null,
// Discovered hosts to test host.update, host.massupdate, host.massadd, host.massremove.
'discovered_no_templates' => null,
'discovered_manual_templates' => null,
'discovered_auto_templates' => null,
'discovered_auto_and_manual_templates' => null,
'discovered_no_macros' => null,
'discovered_manual_macros' => null,
'discovered_auto_macros' => null,
'discovered_auto_and_manual_macros' => null,
// Discovered host to test if items are cleared as well.
'discovered_clear' => null,
// Discovered host to test host.get with limitSelects option.
'discovered_limit_selects' => null
],
'templategroupid' => null,
'templateids' => [
'api_test_hosts_f_tpl' => null,
'api_test_hosts_c_tpl' => null,
'api_test_hosts_a_tpl' => null,
'api_test_hosts_e_tpl' => null,
'api_test_hosts_b_tpl' => null,
'api_test_hosts_d_tpl' => null,
'api_test_hosts_tpl_with_item' => null
],
'maintenanceids' => null,
// Keys must match the macro names. For example discovered_macro_text_a => {$DISCOVERED_MACRO_TEXT_A}
'hostmacroids' => [
'discovered_macro_text_a' => null,
'discovered_macro_secret_a' => null,
'discovered_macro_vault_a' => null,
'discovered_macro_text_b' => null,
'discovered_macro_secret_b' => null,
'discovered_macro_vault_b' => null,
'manual_macro_text_c' => null,
'manual_macro_secret_c' => null,
'manual_macro_vault_c' => null,
'manual_macro_text_d' => null,
'manual_macro_secret_d' => null,