Source
xxxxxxxxxx
$this->assertTrue($row->query(self::SYMPTOM_XPATH)->one(false)->isVisible($data['result'][0] === 'Problem trap>10 [Symptom]'));
<?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';
/**
* @backup !profiles, !problem, !problem_tag, !service_problem, !event_symptom
*
* @onBefore prepareData
*
* @onAfter clearData
*/
class testCauseAndSymptomEvents extends CWebTest {
/**
* Attach TableBehavior and MessageBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return [
CTableBehavior::class,
CMessageBehavior::class
];
}
const COLLAPSE_XPATH = 'xpath:.//button[@title="Collapse"]';
const EXPAND_XPATH = 'xpath:.//button[@title="Expand"]';
const SYMPTOM_XPATH = 'xpath:.//span[@title="Symptom"]';
protected static $groupids;
protected static $triggerids;
protected static $hostsids;
public function prepareData() {
// Create host groups for hosts.
CDataHelper::call('hostgroup.create', [
['name' => 'Group for Cause and Symptom check'],
['name' => 'Group for Cause and Symptom update']
]);
self::$groupids = CDataHelper::getIds('name');
// Create hosts and trapper items.
self::$hostsids = CDataHelper::createHosts([
[
'host' => 'Host for Cause and Symptom check',
'groups' => [
'groupid' => self::$groupids['Group for Cause and Symptom check']
],
'items' => [
[
'name' => 'Consumed energy',
'key_' => 'kWh',
'type' => ITEM_TYPE_TRAPPER,
'value_type' => ITEM_VALUE_TYPE_FLOAT
]
]
],
[
'host' => 'Host for Cause and Symptom check2',
'groups' => [
'groupid' => self::$groupids['Group for Cause and Symptom check']
],
'items' => [
[
'name' => 'Accumulated energy',
'key_' => 'kWh',
'type' => ITEM_TYPE_TRAPPER,
'value_type' => ITEM_VALUE_TYPE_FLOAT
]
]
],
[
'host' => 'Host for Cause and Symptom update',
'groups' => [
'groupid' => self::$groupids['Group for Cause and Symptom update']
],
'items' => [
[