Source
<?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';
/**
* Test for checking empty pages and tables.
*
* @onBefore clearData, prepareEmptyData
*
* @backup profiles
*/
class testPagesWithoutData extends CWebTest {
const EMPTY_HOST = 'Empty host for multiselects test';
const EMPTY_LLD_HOST = 'Host with empty LLD';
const EMPTY_TEMPLATE = 'Empty template for multiselects test';
const EMPTY_LLD_TEMPLATE = 'Template with empty LLD';
protected static $empty_hostid;
protected static $empty_templateid;
protected static $host_lldid;
protected static $template_lldid;
/**
* Attach TableBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return [CTableBehavior::class];
}
/**
* Function for finding and deleting data created before with previous tests.
*/
public function clearData() {
// Delete SLA.
$slaids = CDBHelper::getColumn('SELECT * FROM sla', 'slaid');
if ($slaids !== []) {
CDataHelper::call('sla.delete', array_values($slaids));
}
}
public function prepareEmptyData() {
$hostgroups = CDataHelper::call('hostgroup.create', [['name' => 'Group for empty pages']]);
$host_groupid = $hostgroups['groupids'][0];
$hosts = CDataHelper::createHosts([
[
'host' => self::EMPTY_LLD_HOST,