Source
$table_headers = CTestArrayHelper::get($data, 'fields.Severity', false) ? $data['fields']['Severity'] : $default_values['Severity'];
<?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/CWebTest.php';
require_once dirname(__FILE__).'/../behaviors/CTagBehavior.php';
require_once dirname(__FILE__).'/../../include/helpers/CDataHelper.php';
/**
* @backup widget, profiles
*
* @dataSource UserPermissions
*/
class testDashboardProblemsBySeverityWidget extends CWebTest {
/**
* Attach TagBehavior to the test.
*/
public function getBehaviors() {
return [
[
'class' => CTagBehavior::class,
'tag_selector' => 'id:tags_table_tags'
]
];
}
/**
* Id of the dashboard that is created within this test specifically for the update scenario.
*
* @var integer
*/
protected static $dashboardid;
/*
* SQL query to get widget and widget_field tables to compare hash values, but without widget_fieldid
* because it can change.
*/
private $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_hostid,'.
' wf.value_itemid, wf.value_graphid';
public function getCreateWidgetData() {
return [
// #0 Create a widget with default values.
[
[
'fields' => [
'Type' => 'Problems by severity'
],
'check' => [
'pop-up' => true,
'disabled' => true
]
]
],
// #1 Host groups: 4 tags with Or operator, at least one of them should be present.
[
[
'fields' => [
'Type' => 'Problems by severity',
'Name' => 'HG: Four Or tags in filter',
'Problem tags' => 'Or'
],
'tags' => [
['name' => 'Service', 'operator' => 'Contains', 'value' => ''],
['name' => 'server', 'operator' => 'Contains', 'value' => ''],
['name' => 'Alpha', 'operator' => 'Contains', 'value' => ''],
['name' => 'Delta', 'operator' => 'Contains', 'value' => '']
],
'expected' => [
'Group to check triggers filtering' => [
'Average' => '1'
],
'Host group for tag permissions' => [
'Not classified' => '2'