Source
xxxxxxxxxx
$get_user_rows = $this->webDriver->findElements(WebDriverBy::xpath('//table/tbody/tr['.$i.']/td['.$user_column_number[$user['username']].']'));
<?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/CLegacyWebTest.php';
use Facebook\WebDriver\WebDriverBy;
/**
* @dataSource LoginUsers, Actions, UserPermissions
*/
class testPageReportsNotifications extends CLegacyWebTest {
public function testPageReportsNotifications_CheckLayout() {
$this->zbxTestLogin('report4.php');
$this->zbxTestCheckTitle('Notification report');
$this->zbxTestCheckHeader('Notifications');
// Check dropdown elements
$all_media = [];
foreach (CDBHelper::getAll('SELECT name FROM media_type ORDER BY LOWER(name) ASC') as $name) {
$all_media[] = $name['name'];
}
$dropdowns = [
'media_type' => array_merge(['All'], $all_media),
'period' => ['Daily', 'Weekly', 'Monthly', 'Yearly'],
'year' => array_reverse(range(date("Y"), 2012))
];
$default_selected = [
'media_type' => 'All',
'period' => 'Weekly',
'year' => date('Y')
];
foreach ($dropdowns as $name => $options) {
$dropdown = $this->query('name', $name)->asDropdown()->one();
// Check dropdown options.
$this->assertEquals($options, $dropdown->getOptions()->asText());
// Check default selected dropdown values
$this->assertEquals($default_selected[$name], $dropdown->getText());
}
// Get users from DB
$user_alias = [];
$get_user_alias = DBselect('SELECT username FROM users');
while ($row = DBfetch($get_user_alias)) {
$user_alias[] = $row['username'];
}
sort($user_alias);
$users = [];
$elements = $this->webDriver->findElements(WebDriverBy::xpath('//th/span[@class="text-vertical"]'));
foreach ($elements as $i => $element) {
$users[] = $element->getText();
}
sort($users);
// Check that all users from DB exist in table header on page
foreach ($users as $i => $user) {
$this->assertRegexp('/^'.$user_alias[$i].'( \(.+\))*$/', $users[$i]);
}
}
public static function getUsersNotificationsData() {
return [
// Check report by month and for 2017 year
[
[
'period' => 'Monthly',
'year' => '2017',
'users' => [
[
'username' => 'admin-zabbix',
'notifications' => [ '', '', '', '4', '', '', '', '', '', '', '', '12']
],
[
'username' => 'guest',
'notifications' => [ '', '2', '', '', '', '', '', '', '', '10', '', '']
],