Source
xxxxxxxxxx
$this->assertStringContainsString('host_prototypes.php?form=update&parent_discoveryid=', $this->page->getCurrentUrl());
<?php
/*
** Zabbix
** 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 General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
require_once dirname(__FILE__).'/../../include/CWebTest.php';
require_once dirname(__FILE__).'/../behaviors/CMessageBehavior.php';
require_once dirname(__FILE__).'/../behaviors/CTableBehavior.php';
/**
* @backup hosts
*
* @onBefore preparePageHostGroupsData
*
* @dataSource DiscoveredHosts, HostGroups
*/
class testPageHostGroups extends CWebTest {
/**
* Attach MessageBehavior and TableBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return [
CMessageBehavior::class,
CTableBehavior::class
];
}
const LINK = 'hostgroups.php';
const GROUP_DISABLED = 'Group with two disabled hosts testPageHostGroups';
const HOST1 = 'One disabled host testPageHostGroups';
const HOST2 = 'Two disabled host testPageHostGroups';
const TEMPLATE = 'Template with hosts in group testPageHostGroups';
const GROUP_ENABLED = 'Group with two enabled hosts testPageHostGroups';
const DELETE_GROUP3 = 'Group 3 for Delete test';
/**
* Objects created in dataSource DiscoveredHosts.
*/
const DISCOVERED_GROUP = 'Group created from host prototype 1';
const DISCOVERED_GROUP2 = 'Group created from host prototype 11';
const DISCOVERED_HOST = 'Discovered host from prototype 1';
const HOST_PROTOTYPE = 'Host created from host prototype {#KEY}';
const LLD = 'LLD for Discovered host tests';
/**
* Objects created in dataSource HostGroups for Delete test.
*/
const DELETE_ONE_HOST_GROUP = 'One group belongs to one host for Delete test';
const DELETE_ONE_TEMPLATE_GROUP = 'One group belongs to one template for Delete test';
const DELETE_EMPTY_GROUP = 'Group empty for Delete test';
const DELETE_GROUP2 = 'First group to one object for Delete test';
/**
* SQL query to get groups and hosts to compare hash values.
*/
const GROUPS_SQL = 'SELECT * FROM hstgrp g INNER JOIN hosts_groups hg ON g.groupid=hg.groupid'.
' ORDER BY g.groupid, hg.hostgroupid';
const HOSTS_SQL = 'SELECT * FROM hosts ORDER BY hostid';
/**
* Prepare data for enable/disable hosts test.
*/
public static function preparePageHostGroupsData() {
// Create three groups with disabled hosts and two groups with enabled hosts for testing.
CDataHelper::call('hostgroup.create', [
[
'name' => self::GROUP_DISABLED
],
[
'name' => 'Group with disabled host testPageHostGroups'
],
[