Source
$this->assertEquals(self::$old_widget_count + (($action === 'create') ? 1 : 0), $dashboard->getWidgets()->count());
<?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__).'/../common/testWidgets.php';
/**
* @backup dashboard, globalmacro
*
* @dataSource AllItemValueTypes
*
* @onBefore prepareHoneycombWidgetData
*/
class testDashboardHoneycombWidget extends testWidgets {
/**
* Attach MessageBehavior, TagBehavior and TableBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return [
CMessageBehavior::class,
CTagBehavior::class,
CTableBehavior::class
];
}
/**
* Ids of created Dashboards for Honeycomb widget check.
*/
protected static $dashboardid;
/**
* Hash before TEST_BAD scenario.
*/
protected static $old_hash;
/**
* Widget amount before create/update.
*/
protected static $old_widget_count;
/**
* Id of dashboard for update scenarios.
*/
protected static $disposable_dashboard_id;
const DASHBOARD_FOR_MACRO_FUNCTIONS = 'Dashboard for testing macro functions';
const WIDGET_FOR_MACRO_FUNCTIONS = 'Widget for testing macro functions';
public static function prepareHoneycombWidgetData() {
CDataHelper::call('hostgroup.create', [
[
'name' => 'Maintenance group'
],
[
'name' => 'Host with tags'
],
[
'name' => 'Items with tags'
]
]);
$groupids = CDataHelper::getIds('name');
$response = CDataHelper::createHosts([
[
'host' => 'Host for honeycomb 1',
'groups' => [['groupid' => 4]], // Zabbix servers.
'items' => [
[
'name' => 'Numeric for honeycomb 1',
'key_' => 'num_honey_1',
'type' => ITEM_TYPE_TRAPPER,
'value_type' => ITEM_VALUE_TYPE_UINT64
]
]
],
[