Source
xxxxxxxxxx
* @backup !problem, !events, !event_tag, !problem_tag, !alerts, !service_problem, !event_symptom, !acknowledges, !event_recovery, !event_suppress
<?php
/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
require_once dirname(__FILE__).'/../../include/CWebTest.php';
require_once dirname(__FILE__).'/../behaviors/CMessageBehavior.php';
require_once dirname(__FILE__).'/../behaviors/CTableBehavior.php';
require_once dirname(__FILE__).'/../behaviors/CTagBehavior.php';
/**
* @backup dashboard
*
* @onBefore prepareData
*/
class testDashboardTopTriggersWidget extends CWebTest {
/**
* Attach MessageBehavior, TableBehavior and TagBehavior to the test.
*/
public function getBehaviors() {
return [
CMessageBehavior::class,
CTableBehavior::class,
[
'class' => CTagBehavior::class,
'tag_selector' => 'id:tags_table_tags'
]
];
}
protected static $dashboardid;
protected static $dashboard_create;
protected static $dashboard_data;
protected static $groupids;
protected static $update_widget = 'Update Top triggers widget';
const DEFAULT_WIDGET = 'Default Top triggers widget';
const DELETE_WIDGET = 'Widget for delete';
const DATA_WIDGET = 'Widget for data check';
/**
* SQL query to get widget and widget_field tables to compare hash values, but without widget_fieldid
* because it can change.
*/
const SQL = 'SELECT wf.widgetid, wf.type, wf.name, wf.value_int, wf.value_str, wf.value_groupid, wf.value_hostid,'.
' wf.value_itemid, wf.value_graphid, wf.value_sysmapid, w.widgetid, w.dashboard_pageid, w.type, w.name, w.x, w.y,'.
' w.width, w.height'.
' FROM widget_field wf'.
' INNER JOIN widget w'.
' ON w.widgetid=wf.widgetid ORDER BY wf.widgetid, wf.name, wf.value_int, wf.value_str, wf.value_groupid,'.
' wf.value_itemid, wf.value_graphid';
public static function prepareData() {
// Create hostgroups for hosts.
CDataHelper::call('hostgroup.create', [
['name' => 'First Group for TOP triggers check'],
['name' => 'Second Group for TOP triggers check']
]);
self::$groupids = CDataHelper::getIds('name');
// Create hosts and trapper items for top triggers data test.
CDataHelper::createHosts([
[
'host' => 'Host with top triggers trapper',
'interfaces' => [
[
'type' => INTERFACE_TYPE_AGENT,
'main' => INTERFACE_PRIMARY,
'useip' => INTERFACE_USE_IP,
'ip' => '127.0.9.1',
'dns' => '',
'port' => '10077'
]
],
'groups' => [