Source
xxxxxxxxxx
// Verify that there is no possibility to delete selected script(s) if at least one of them contains linked action.
<?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 scripts
*
* @dataSource HostGroups
*
* @onBefore prepareScriptData
*/
class testPageAdministrationScripts extends CWebTest {
/**
* Attach MessageBehavior and TableBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return [
CMessageBehavior::class,
CTableBehavior::class
];
}
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',
'esc_step_from' => '1',
'esc_step_to' => '1',
'operationtype' => OPERATION_TYPE_COMMAND,
'opcommand' => [
'scriptid' => $scriptids[self::$custom_script]