Source
xxxxxxxxxx
$this->assertEquals(CTestArrayHelper::get($data, 'parent_rootcause', ''), $row->getColumn('Root cause')->getText());
<?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';
/**
* @dataSource EntitiesTags, Services, Actions
*
* @backup services
*/
class testPageServicesServices extends CWebTest {
/**
* Attach MessageBehavior and TableBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return [
CMessageBehavior::class,
CTableBehavior::class
];
}
const EDIT = true;
const SERVICE_COUNT = 20;
const LAYOUT_PARENT = 'Parent for 2 levels of child services';
const LAYOUT_CHILD = 'Child service with child service';
const LAYOUT_CHILD2 = 'Child service of child service';
const ROOTCAUSE_PARENT = 'Test order';
const ROOTCAUSE_CHILD1 = '1';
const ROOTCAUSE_CHILD2 = '2';
const ROOTCAUSE_CHILD3 = '3';
const BREADCRUMB_SELECTOR = 'xpath://ul[@class="breadcrumbs"]';
const TABLE_SELECTOR = 'id:service-list';
/**
* Set parent and child services to Problem status and link the child services to the corresponding problem events.
*/
public static function prepareServiceProblemsData() {
// Statuses: Warning = 2, Average = 3, High = 4.
$service_statuses = [
self::ROOTCAUSE_PARENT => 4,
self::ROOTCAUSE_CHILD1 => 2,
self::ROOTCAUSE_CHILD2 => 3,
self::ROOTCAUSE_CHILD3 => 4
];
$service_ids = [];
$i = 1;
foreach ($service_statuses as $service => $status) {
$service_ids[$service] = CDBHelper::getValue('SELECT serviceid FROM services WHERE name='.zbx_dbstr($service));
// Change service status to Problem with the corresponding severity.
DBexecute('UPDATE services SET status='.zbx_dbstr($status).' WHERE serviceid='.zbx_dbstr($service_ids[$service]));
// Link child services to the corresponding problem events.
if ($service !== self::ROOTCAUSE_PARENT) {
// Corresponding trigger problem events have ids starting from 9001 in data_test.sql, so "9000 + $i" is used.
DBexecute('INSERT into service_problem (service_problemid, eventid, serviceid, severity) '.
'VALUES ('.$i.', '.(9000 + $i).', '.$service_ids[$service].', '.$status.')'
);
$i++;
}
}
}
public function testPageServicesServices_LayoutView() {
$this->page->login()->open('zabbix.php?action=service.list');
$this->page->assertTitle('Services');