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/>.
**/
class TopHostsWidget {
const ZABBIX_SERVER_HOSTID = 10084; // ЗАББИКС Сервер.
/**
* Create data for testDashboardTopHostsWidget test.
*
* @return array
*/
public static function load() {
// Create items with value type - text, log, character.
CDataHelper::call('item.create', [
[
'name' => 'top_hosts_trap_text',
'key_' => 'top_hosts_text',
'hostid' => self::ZABBIX_SERVER_HOSTID,
'type' => ITEM_TYPE_TRAPPER,
'value_type' => ITEM_VALUE_TYPE_TEXT
],
[
'name' => 'top_hosts_text2',
'key_' => 'top_hosts_text2',
'hostid' => self::ZABBIX_SERVER_HOSTID,
'type' => ITEM_TYPE_TRAPPER,
'value_type' => ITEM_VALUE_TYPE_TEXT
],
[
'name' => 'top_hosts_trap_log',
'key_' => 'top_hosts_log',
'hostid' => self::ZABBIX_SERVER_HOSTID,
'type' => ITEM_TYPE_TRAPPER,
'value_type' => ITEM_VALUE_TYPE_LOG
],
[
'name' => 'top_hosts_trap_char',
'key_' => 'top_hosts_char',
'hostid' => self::ZABBIX_SERVER_HOSTID,
'type' => ITEM_TYPE_TRAPPER,
'value_type' => ITEM_VALUE_TYPE_STR
]
]);
$itemids = CDataHelper::getIds('name');
// Create dashboards for Top host widget testing.
CDataHelper::call('dashboard.create', [
[