Source
'Cannot add more than one item with type "Graph sum" on graph "Exploded graph duplicated Graph sum type".'
<?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 __DIR__.'/../common/testFormGraphs.php';
/**
* @backup graphs
*
* @onBefore prepareGraphsData
*
* @onAfter clearData
*
* @dataSource WebScenarios, AllItemValueTypes
*/
class testFormGraph extends testFormGraphs {
protected $url = 'graphs.php?filter_set=1&filter_hostids%5B0%5D='.self::HOSTID.'&context=host';
public function prepareGraphsData() {
self::$update_graph = 'Graph for update';
// Create items on given host.
$items_data = [];
foreach (self::$items['items'] as $name => $fields) {
$items_data[] = [
'hostid' => self::HOSTID,
'name' => $name,
'key_' => $name,
'type' => ITEM_TYPE_TRAPPER,
'value_type' => $fields['value_type']
];
}
$items = CDataHelper::call('item.create', $items_data);
$this->assertArrayHasKey('itemids', $items);
$itemids = CDataHelper::getIds('name');
foreach (['int', 'float', 'text', 'log'] as $suffix) {
$field = 'graph_trap_'.$suffix;
self::$items[$field]['itemid'] = $itemids[$field];
}
// Create graphs with previously created items.
$prepared_graphs = [
[
'name' => 'Graph for update',
'itemid' => self::$items['graph_trap_int']['itemid']
],
[
'name' => 'Graph for delete',
'itemid' => self::$items['graph_trap_float']['itemid']
],
[
'name' => 'Duplicated graph',
'itemid' => self::$items['graph_trap_float']['itemid']
],
[
'name' => 'Graph for clone',
'itemid' => self::$items['graph_trap_int']['itemid']
],
[
'name' => 'Graph for items change',
'itemid' => self::$items['graph_trap_int']['itemid']
]
];
$graphs_data = [];
foreach ($prepared_graphs as $graph) {
$graphs_data[] = [
'name' => $graph['name'],
'width' => 850,
'height' => 335,
'gitems' => [
[
'itemid' => $graph['itemid'],
'color'=> 'FDD835'
]
]