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/>.
**/
require_once dirname(__FILE__).'/../common/testWidgetCommunication.php';
/**
* @backup profiles
*
* @dataSource WidgetCommunication, Sla
*
* @onBefore prepareWidgetData
*/
class testDashboardWidgetBroadcastedData extends testWidgetCommunication {
const TEST_BROADCASTER_REFERENCES = [
'Hostgroups page' => 'RAHQZ',
'Hosts page' => 'ZQHBC',
'Items page' => 'KJRCA',
'Maps page' => 'SALAT'
];
const ENTITY_DATA = [
'Hostgroups page' => [
'type' => 'hostgroupids',
'text' => '_hostgroupids'
],
'Hosts page' => [
'type' => 'hostids',
'text' => '_hostids'
],
'Items page' => [
'type' => 'itemids',
'text' => '_itemid'
],
'Maps page' => [
'type' => 'mapids',
'text' => '_mapid'
]
];
public static function prepareWidgetData() {
testWidgetCommunication::getCreatedIds();
// Discover the Test broadcaster and Test listener widget modules.
CDataHelper::call('module.create', [
[
'id' => 'testbroadcaster',
'relative_path' => 'modules/testbroadcaster',
'status' => MODULE_STATUS_ENABLED
],
[
'id' => 'testlistener',
'relative_path' => 'modules/testlistener',
'status' => MODULE_STATUS_ENABLED
]
]);
// Add broadcaster and listener widgets for widgets involved in widget communication tests (except mixed scenarios).
$dashboard_content = CDataHelper::call('dashboard.get', [
'dashboardids' => self::$entityids['dashboardid'],
'selectPages' => 'extend'
])[0];
$used_pages = [
'Hostgroups page' => 'groupids',
'Hosts page' => 'hostids',
'Items page' => 'itemid',
'Maps page' => 'sysmapid'
];
$dashboard_page = [];
$pageids = [];
// Create an array with only the required pages.
foreach ($dashboard_content['pages'] as $existing_page) {
if (in_array($existing_page['name'], array_keys($used_pages))) {
$dashboard_page[$existing_page['name']] = $existing_page['widgets'];
$pageids[$existing_page['name']] = $existing_page['dashboard_pageid'];
}