Source
$table = CDashboardElement::find()->one()->getWidget($data['fields']['Name'])->query('class:list-table')->asTable()->one();
<?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 __DIR__.'/../../include/CWebTest.php';
require_once __DIR__.'/../behaviors/CMessageBehavior.php';
require_once __DIR__.'/../behaviors/CTableBehavior.php';
class testSlaReport extends CWebTest {
/**
* Attach MessageBehavior and TableBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return [
CMessageBehavior::class,
CTableBehavior::class
];
}
public static $reporting_periods = [];
public static $period_headers = [
'Daily' => 'Day',
'Weekly' => 'Week',
'Monthly' => 'Month',
'Quarterly' => 'Quarter',
'Annually' => 'Year'
];
private static $actual_creation_time; // Actual timestamp when data source was executed.
private static $service_creation_time; // Service "Service with problem" creation time, needed for downtime calculation.
const SLA_CREATION_TIME = 1619827200; // SLA creation timestamp as per scenario - 01.05.2021
public function getSlaDataWithService() {
return [
// Daily with downtime.
[
[
'fields' => [
'SLA' => 'SLA Daily',
'Service' => 'Service with problem'
],
'reporting_period' => 'Daily',
'downtimes' => ['EXCLUDED DOWNTIME', 'Second downtime'],
'check_sorting' => true,
'expected' => [
'SLO' => '11.111'
]