Source
<?php
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
require_once dirname(__FILE__).'/../../include/CWebTest.php';
require_once dirname(__FILE__).'/../traits/TagTrait.php';
require_once dirname(__FILE__).'/../../include/helpers/CDataHelper.php';
/**
* @dataSource TopHostsWidget
*
* @backup widget, profiles, dashboard, items
*/
class testDashboardTopHostsWidget extends CWebTest {
use TagTrait;
/**
* Widget name for update.
*/
private static $updated_name = 'Top hosts update';
/**
* 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';
/**
* Attach MessageBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return [
CMessageBehavior::class
];
}
public static function getCreateData() {
return [
// #0 minimum needed values to create and submit widget.
[
[
'expected' => TEST_GOOD,
'main_fields' => [],
'column_fields' => [
[
'Data' => 'Item value',
'Item' => 'Available memory'
]
]
]
],
// #1 all fields filled for main form with all tags.
[
[
'expected' => TEST_GOOD,
'main_fields' => [
'Name' => 'Name of Top hosts widget',
'Refresh interval' => 'Default (1 minute)',
'Host groups' => 'Zabbix servers',
'Hosts' => 'ЗАББИКС Сервер',
'Order' => 'Bottom N',
'Host count' => '99'
],
'tags' => [
['name' => 'value', 'value' => '12345', 'operator' => 'Contains'],
['name' => '@#$%@', 'value' => 'a1b2c3d4', 'operator' => 'Equals'],