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/CIntegrationTest.php';
/**
* Test case to check if an item preprocessing "custom on fail" supports
* macros in error handler parameter. Both "set value to" and "set error to"
* are checked in this test case.
*
* @backup hosts
*/
class testCustomOnFail extends CIntegrationTest {
private static $hostid;
private static $master_itemid;
private static $dep1_itemid;
private static $dep2_itemid;
const HOST_NAME = 'test';
const MASTER_ITEM_NAME = 'master';
const DEP_ITEM1_NAME = 'dep1';
const DEP_ITEM2_NAME = 'dep2';
const TEST_MACRO_NAME = '{$TEST.MACRO}';
const TEST_MACRO_VALUE = '5';
/**
* Create a host with 1 macro and 3 items to test preprocessing.
*/
public function prepareData() {
// Create the host
$response = $this->call('host.create', [
'host' => self::HOST_NAME,
'interfaces' => [
[
'type' => 1,
'main' => 1,
'useip' => 1,
'ip' => '127.0.0.1',
'dns' => '',
'port' => $this->getConfigurationValue(self::COMPONENT_AGENT, 'ListenPort')
]
],
'groups' => [
[
'groupid' => 4
]
]
]);
$this->assertArrayHasKey('hostids', $response['result']);