Source
xxxxxxxxxx
$this->page->login()->open('zabbix.php?action=trigger.list&filter_hostids%5B0%5D='.self::$hostids['Host with everything'].
<?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__).'/../common/testTriggerDependencies.php';
/**
* @backup hosts
*
* @onBefore prepareHostTriggersData
*/
class testHostTriggerDependencies extends testTriggerDependencies {
protected static $hostids;
protected static $host_druleids;
public function prepareHostTriggersData() {
$template_result = CDataHelper::createTemplates([
[
'host' => 'Template that linked to host',
'groups' => ['groupid' => 1],
'items' => [
[
'name' => 'template item for linking',
'key_' => 'everything_2',
'type' => ITEM_TYPE_TRAPPER,
'value_type' => ITEM_VALUE_TYPE_UINT64,
'delay' => 0
]
],
'discoveryrules' => [
[
'name' => 'Drule for linking',
'key_' => 'linked_drule',
'type' => ITEM_TYPE_TRAPPER,
'delay' => 0
]
]
]
]);
$templateids = $template_result['templateids'];
$template_druleids = $template_result['discoveryruleids'];
$template_triggers = CDataHelper::call('trigger.create', [
[
'description' => 'Trigger that linked',
'expression' => 'last(/Template that linked to host/everything_2)=0'
]
]);
$this->assertArrayHasKey('triggerids', $template_triggers);
$item_prototype = CDataHelper::call('itemprototype.create', [
[
'name' => 'Item prot for linking',
'key_' => 'linking_prot_[{#KEY}]',
'hostid' => $templateids['Template that linked to host'],
'ruleid' => $template_druleids['Template that linked to host:linked_drule'],
'type' => ITEM_TYPE_TRAPPER,
'value_type' => ITEM_VALUE_TYPE_UINT64,
'delay' => 0
]
]);
$this->assertArrayHasKey('itemids', $item_prototype );
$trigger_prototype = CDataHelper::call('triggerprototype.create', [
[
'description' => 'trigger prototype linked{#KEY}',
'expression' => 'last(/Template that linked to host/linking_prot_[{#KEY}])=0'
],
[
'description' => 'trigger prototype linked update{#KEY}',
'expression' => 'last(/Template that linked to host/linking_prot_[{#KEY}])=0'
]
]);
$this->assertArrayHasKey('triggerids', $trigger_prototype);
$host_result = CDataHelper::createHosts([
[
'host' => 'Host with linked template',