Source
$id = CDBHelper::getValue('SELECT druleid FROM drules WHERE name='.zbx_dbstr('Discovery rule for proxy delete test'));
<?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';
/**
* @backup widget
*
* @onBefore prepareDiscoveryStatusWidgetData
*
* @dataSource Proxies
*/
class testDashboardDiscoveryStatusWidget extends CWebTest {
/**
* Attach MessageBehavior and TableBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return [
CMessageBehavior::class,
CTableBehavior::class
];
}
/**
* Id of the dashboard with widgets.
*
* @var integer
*/
protected static $dashboardid;
protected static $druleids;
protected static $update_widget = 'Update widget';
const DISCOVERY_RULE_1 = 'A discovery rule to be displayed first';
const DISCOVERY_RULE_2 = 'Discovery rule with 0 discovered hosts';
const DISCOVERY_RULE_3 = 'Discovery rule with active discovered hosts';
const DISCOVERY_RULE_4 = 'Discovery rule with both type of hosts';
const DISCOVERY_RULE_5 = 'XYZ - discovery rule to be displayed last (Inactive hosts)';
const DELETE_WIDGET = 'Discovery status widget to delete';
const DATA_WIDGET = 'Widget for data check';
const CANCEL_WIDGET = 'Widget for testing cancel button';
/**
* SQL query to get widget and widget_field tables to compare hash values, but without widget_fieldid
* because it can change.
*/
const 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 test data.
*
* @return array
*/
public static function prepareDiscoveryStatusWidgetData() {
CDataHelper::call('drule.create', [
[
'name' => self::DISCOVERY_RULE_1,
'iprange' => '192.168.1.1-255',
'dchecks' => [
[
'type' => SVC_HTTP
]
]
],
[
'name' => self::DISCOVERY_RULE_2,
'iprange' => '192.168.1.1-255',
'dchecks' => [
[
'type' => SVC_HTTP