Source
'value' => $itemids['Test Item history'] // item name in widget 'Simple host with item for Item history widget: Test Item history'.
<?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';
require_once dirname(__FILE__).'/../common/testWidgets.php';
/**
* @backup dashboard
*
* @onBefore prepareData
*
* @dataSource AllItemValueTypes
*/
class testDashboardItemHistoryWidget extends testWidgets {
/**
* Attach MessageBehavior and TableBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return [
CMessageBehavior::class,
CTableBehavior::class
];
}
const DEFAULT_WIDGET = 'Default Item history Widget';
const DELETE_WIDGET = 'Widget for delete';
const DATA_WIDGET = 'Widget for data check';
protected static $dashboardid;
protected static $dashboard_create;
protected static $dashboard_data;
protected static $update_widget = 'Update Item history Widget';
public static function prepareData() {
// Create host for widget header and data tests.
CDataHelper::createHosts([
[
'host' => 'Simple host with item for Item history widget',
'interfaces' => [
[
'type' => INTERFACE_TYPE_AGENT,
'main' => INTERFACE_PRIMARY,
'useip' => INTERFACE_USE_IP,
'ip' => '127.0.9.1',
'dns' => '',
'port' => '10077'
]
],
'groups' => [
'groupid' => '4'
],
'items' => [
[
'name' => 'Test Item history',
'key_' => 'plain_text',
'type' => ITEM_TYPE_ZABBIX,
'value_type' => ITEM_VALUE_TYPE_FLOAT,
'delay' => '30'
]
]
]
]);
$itemids = CDataHelper::getIds('name');
$response = CDataHelper::call('dashboard.create', [
[
'name' => 'Dashboard for Item history Widget test',
'pages' => [
[
'name' => 'Page with default widgets',
'widgets' => [
[
'type' => 'itemhistory',