Source
xxxxxxxxxx
$this->assertEquals(($scripts_count > 1) ? 'Delete selected scripts?' : 'Delete selected script?', $this->page->getAlertText());
<?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';
require_once dirname(__FILE__).'/../behaviors/CMessageBehavior.php';
require_once dirname(__FILE__).'/../behaviors/CTableBehavior.php';
/**
* @backup scripts
*
* @dataSource HostTemplateGroups, Actions
*
* @onBefore prepareScriptData
*/
class testPageAlertsScripts extends CWebTest {
/**
* Attach MessageBehavior and TableBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return [
CMessageBehavior::class,
[
'class' => CTableBehavior::class,
'column_names' => ['', 'Name', 'Scope', 'Count', 'Used in actions', 'Type', 'Execute on', 'Commands',
'User group', 'Host group', 'Host access'
]
]
];
}
/**
* Script created in dataSource HostTemplateGroups.
*/
const HOST_GROUP_SCRIPT = 'Script for host group testing';
private static $script_sql = 'SELECT * FROM scripts ORDER BY scriptid';
private static $custom_script = 'Custom script with linked action';
private static $script_for_filter = 'Script для фильтра - $¢Řĩ₱₮';
private static $script_scope_event = 'Manual event action for filter check';
private static $custom_action = 'Trigger action for Scripts page testing';
public function prepareScriptData() {
CDataHelper::call('script.create', [
[
'name' => self::$script_scope_event,
'type' => ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT,
'scope' => ZBX_SCRIPT_SCOPE_EVENT,
'command' => 'test'
],
[
'name' => self::$script_for_filter,
'type' => ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT,
'scope' => ZBX_SCRIPT_SCOPE_EVENT,
'command' => '/sbin/run'
],
[
'name' => self::$custom_script,
'type' => ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT,
'scope' => ZBX_SCRIPT_SCOPE_ACTION,
'command' => '/sbin/zabbix_server --runtime-control config_cache_reload',
'groupid' => '4',
'description' => 'This command reload cache.'
]
]);
$scriptids = CDataHelper::getIds('name');
// Create trigger action
CDataHelper::call('action.create', [
'esc_period' => '1m',
'eventsource' => EVENT_SOURCE_TRIGGERS,
'status' => ACTION_STATUS_ENABLED,
'name' => self::$custom_action,
'operations' => [
[
'esc_period' => '0',