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';
/**
* @backup triggers
*
* @onBefore prepare_trigger_data
* @onAfter cleanup_trigger_data
*/
class testTriggers extends CAPITest {
public function prepare_trigger_data(): void {
$result = $this->call('item.create', [
'hostid' => '50009',
'name' => 'master.item',
'key_' => 'master.item',
'type' => ITEM_TYPE_ZABBIX,
'value_type' => ITEM_VALUE_TYPE_FLOAT,
'interfaceid' => 50022,
'delay' => '1m'
]);
$master_itemid = reset($result['result']['itemids']);
$result = $this->call('item.create', [
'hostid' => '50009',
'name' => 'binary.item',
'key_' => 'binary.item',
'type' => ITEM_TYPE_DEPENDENT,
'master_itemid' => $master_itemid,
'value_type' => ITEM_VALUE_TYPE_BINARY
]);
}
public function cleanup_trigger_data(): void {
$result = $this->call('item.get', [
'filter' => [
'key_' => 'master.item'
]
]);
$master_itemid = reset($result['result']['itemids']);
$this->call('item.delete', [$master_itemid]);
}
public static function trigger_get_data() {
$triggerids = ['134118', '134000', '134001', '134002', '134003', '134004', '134005'];
$dependent_triggerids = ['134004', '134005'];