Source
xxxxxxxxxx
$this->assertEquals(['Type', 'Show header', 'Name', 'Refresh interval', 'SLA', 'Service', 'Show periods', 'From', 'To'],
<?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/testSlaReport.php';
require_once dirname(__FILE__).'/../../include/helpers/CDataHelper.php';
/**
* @backup dashboard, profiles
*
* @dataSource Services, Sla
*
* @onBefore prepareDashboardData
* @onBefore getDateTimeData
*/
class testDashboardSlaReportWidget extends testSlaReport {
private static $dashboardid;
private static $slaid;
private static $monthly_sla = 'SLA Monthly';
private static $create_page = 'Page for creating widgets';
private static $update_widget = 'Update widgets';
private static $delete_widget = 'Widget for delete';
private static $default_values = [
'SLA' => '',
'Service' => '',
'From' => '',
'To' => '',
'Show periods' => 20
];
/*
* 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_itemid, wf.value_graphid';
/**
* Create dashboards with widgets for test and define the corresponding dashboard ID.
*/
public static function prepareDashboardData() {
self::$slaid = CDBHelper::getValue('SELECT slaid FROM sla WHERE name='.zbx_dbstr(self::$monthly_sla));
$response = CDataHelper::call('dashboard.create', [
[
'name' => 'Dashboard for SLA report widget tests',
'private' => 0,
'auto_start' => 1,
'pages' => [
[
'name' => 'Page with widgets',
'widgets' => [
[
'type' => 'slareport',
'name' => self::$update_widget,
'width' => 72,
'height' => 3,
'fields' => [
[
'type' => 10,
'name' => 'slaid',
'value' => self::$slaid
]
]
],
[
'type' => 'slareport',
'name' => self::$delete_widget,
'x' => 0,
'y' => 3,
'width' => 72,
'height' => 3,