Source
<?php
/*
** Zabbix
** Copyright (C) 2001-2023 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/CIntegrationTest.php';
/**
* Test suite for testing changing rank of trigger-based events/problems
*
* @required-components server
* @backup hosts,items,triggers,task,task_data,acknowledges,event_symptom,events,problem
*/
class testEventsCauseAndSymptoms extends CIntegrationTest {
private static $hostid;
private static $trigger_ids = [];
private static $event_ids = [];
private static $cause_events_test_scriptid;
private static $symptom_events_test_scriptid;
const HOST_NAME = 'host cause and symptoms';
const TRAPPER_ITEM_NAME_PREFIX = 'Trapper item ';
const TRAPPER_ITEM_KEY_PREFIX = 'trap';
const EVENT_CAUSE_MACRO_TEMPLATE = 'Macros to test: {EVENT.NAME}|{EVENT.ID}|{EVENT.CAUSE.NAME}|{EVENT.CAUSE.ID}|{EVENT.CAUSE.SOURCE}|{EVENT.CAUSE.OBJECT}|{EVENT.CAUSE.VALUE}';
const EVENT_SYMPTOMS_MACRO_TEMPLATE = '{EVENT.SYMPTOMS}';
const TEST_CAUSE_EVENTS_SCRIPT_NAME = 'script test cause events';
const TEST_SYMPTOM_EVENTS_SCRIPT_NAME = 'script test symptom events';
const EVENT_COUNT = 5;
const EVENT_START = 1;
private function expandMacros($in_str, $event_n, $cause_n = null) {
$replacements = [
'{EVENT.NAME}' => 'Trigger trap '.$event_n,
'{EVENT.ID}' => $this->eventNumToId($event_n)
];
if (null != $cause_n) {
$replacements = array_merge($replacements, [
'{EVENT.CAUSE.NAME}' => 'Trigger trap '.$cause_n,
'{EVENT.CAUSE.ID}' => $this->eventNumToId($cause_n),
'{EVENT.CAUSE.SOURCE}' => EVENT_SOURCE_TRIGGERS,
'{EVENT.CAUSE.OBJECT}' => EVENT_OBJECT_TRIGGER,
'{EVENT.CAUSE.VALUE}' => self::EVENT_START
]);
}
$from = [];
$to = [];