Source
'Show', 'Override host', 'Advanced configuration', 'Angle', 'Description', 'Value', 'Value arc', 'Needle', 'Scale',
<?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/CMessageBehavior.php';
require_once dirname(__FILE__).'/../behaviors/CTableBehavior.php';
/**
* @backup config, widget, globalmacro
*
* @dataSource AllItemValueTypes, GlobalMacros
*
* @onBefore prepareDashboardData
*/
class testDashboardGaugeWidget extends testWidgets {
/**
* Attach MessageBehavior and TableBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return [
CMessageBehavior::class,
CTableBehavior::class
];
}
const HOST = 'Host for all item value types';
const DELETE_GAUGE = 'Gauge for deleting';
const GAUGE_ITEM = 'Float item';
const GAUGE_MACROFUNCTIONS = 'Gauge for macrofunctions';
/**
* Id of the dashboard where gauge widget is created and updated.
*
* @var integer
*/
protected static $dashboardid;
protected static $macrofunction_dashboardid;
protected static $update_gauge = 'Gauge for updating';
/**
* Get Thresholds table element with mapping set.
*
* @return CMultifieldTable
*/
protected function getThresholdsTable() {
return $this->query('id:thresholds-table')->asMultifieldTable([
'mapping' => [
'' => [
'name' => 'color',
'selector' => 'class:color-picker',
'class' => 'CColorPickerElement'
],
'Threshold' => [
'name' => 'threshold',
'selector' => 'xpath:./input',
'class' => 'CElement'
]
]
])->waitUntilVisible()->one();
}
public function prepareDashboardData() {
$float_item_id =CDataHelper::get('AllItemValueTypes.itemids.Float item');
// Add item data to move needle on Gauge.
CDataHelper::addItemData($float_item_id, 50);
$dashboards = CDataHelper::call('dashboard.create', [
[
'name' => 'Gauge widget dashboard',
'auto_start' => 0,
'pages' => [
[
'name' => 'Gauge test page',