Source
'expected_error' => 'Discovery rule "drule.used.in.action.1" is used in "drule.discovery.action" action.'
<?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/CAPITest.php';
require_once __DIR__.'/../include/helpers/CTestDataHelper.php';
/**
* @onBefore prepareTestData
* @onAfter cleanTestData
*/
class testDRule extends CAPITest {
public static function prepareTestData(): void {
CTestDataHelper::enableGuestUser();
CTestDataHelper::createObjects([
'template_groups' => [
['name' => 'drule.template.group']
],
'templates' => [
['host' => 'drule.template']
],
'proxies' => [
['name' => 'drule.proxy']
],
'drules' => [
['name' => 'drule.used.in.action.1'],
['name' => 'drule.used.in.action.2'],
['name' => 'drule.del.1'],
['name' => 'drule.del.2'],
['name' => 'drule.del.3'],
['name' => 'drule.perm.del'],
[
'name' => 'drule.with.proxy',
'proxyid' => ':proxy:drule.proxy'
]
],
'actions' => [
[
'name' => 'drule.discovery.action',
'eventsource' => EVENT_SOURCE_DISCOVERY,
'filter' => [
'evaltype' => CONDITION_EVAL_TYPE_OR,
'conditions' => [
[
'conditiontype' => ZBX_CONDITION_TYPE_DRULE,
'operator' => CONDITION_OPERATOR_EQUAL,
'value' => ':drule:drule.used.in.action.1'
],
[
'conditiontype' => ZBX_CONDITION_TYPE_DRULE,