Source
DBexecute("INSERT INTO history (itemid, clock, value, ns) VALUES (".zbx_dbstr(self::$data['itemids']['last']).
<?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';
/**
* @onBefore prepareItemsData, prepareMapsData, writeValuesToItems
*
* @onAfter clearData
*/
class testExpandExpressionMacros extends CWebTest {
protected static $data = [
'hostgroupid',
'hostids' => [
'last' => null,
'avg' => null,
'min' => null,
'max' => null
],
'itemids' => [
'last' => null,
'avg' => null,
'min' => null,
'max' => null
],
'mapid'
];
public function prepareItemsData() {
// Create hostgroup for hosts with items and graphs.
$hostgroups = CDataHelper::call('hostgroup.create', [
[
'name' => 'Group for macro expand testing'
]
]);
$this->assertArrayHasKey('groupids', $hostgroups);
self::$data['hostgroupid'] = $hostgroups['groupids'][0];
// Create hosts for items and graphs.
$hosts_data = [];
foreach (['Last', 'Avg', 'Min', 'Max'] as $type) {
$hosts_data[] = [
'host' => 'Host for expression macro '.$type,
'groups' => [
['groupid' => self::$data['hostgroupid']]
]
];
}
$hosts = CDataHelper::call('host.create', $hosts_data);