1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
<?php
/*
** Zabbix
** Copyright (C) 2001-2018 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/CLegacyWebTest.php';
class testPageMaintenance extends CLegacyWebTest {
// Returns all maintenances
public static function allMaintenances() {
return CDBHelper::getDataProvider('select * from maintenances');
}
/**
* @dataProvider allMaintenances
*/
public function testPageMaintenance_CheckLayout($maintenance) {
$this->zbxTestLogin('maintenance.php');
$this->zbxTestDropdownSelectWait('groupid', 'all');
$this->zbxTestCheckTitle('Configuration of maintenance periods');
$this->zbxTestCheckHeader('Maintenance periods');
$this->zbxTestTextPresent('Displaying');
$this->zbxTestTextNotPresent('Displaying 0');
$this->zbxTestTextPresent(['Name', 'Type', 'Active since', 'Active till', 'State', 'Description']);
$this->zbxTestTextPresent($maintenance['name']);
if ($maintenance['maintenance_type'] == MAINTENANCE_TYPE_NORMAL) $this->zbxTestTextPresent('With data collection');
if ($maintenance['maintenance_type'] == MAINTENANCE_TYPE_NODATA) $this->zbxTestTextPresent('No data collection');
}
/**
* @dataProvider allMaintenances
*/
public function testPageMaintenance_SimpleUpdate($maintenance) {
$this->markTestSkipped();
$name = $maintenance['name'];
$maintenanceid = $maintenance['maintenanceid'];
$sqlMaintenance = "select * from maintenances where name='$name' order by maintenanceid";
$oldHashMaintenance = CDBHelper::getHash($sqlMaintenance);
$sqlHosts = "select * from maintenances_hosts where maintenanceid=$maintenanceid order by maintenance_hostid";
$oldHashHosts = CDBHelper::getHash($sqlHosts);
$sqlGroups = "select * from maintenances_groups where maintenanceid=$maintenanceid order by maintenance_groupid";
$oldHashGroups = CDBHelper::getHash($sqlGroups);
$sqlWindows = "select * from maintenances_windows where maintenanceid=$maintenanceid order by maintenance_timeperiodid";
$oldHashWindows = CDBHelper::getHash($sqlWindows);
$sqlTimeperiods = "select * from timeperiods where timeperiodid in (select timeperiodid from maintenances_windows where maintenanceid=$maintenanceid) order by timeperiodid";
$oldHashTimeperiods = CDBHelper::getHash($sqlTimeperiods);
$this->zbxTestLogin('maintenance.php');
$this->zbxTestDropdownSelectWait('groupid', 'all');
$this->zbxTestCheckTitle('Configuration of maintenance periods');
$this->zbxTestClickLinkText($name);
$this->zbxTestClickWait('update');
$this->zbxTestCheckTitle('Configuration of maintenance periods');
$this->zbxTestTextPresent('Maintenance updated');
$this->zbxTestTextPresent("$name");
$this->zbxTestTextPresent('Maintenance periods');
$this->assertEquals($oldHashMaintenance, CDBHelper::getHash($sqlMaintenance), "Chuck Norris: Maintenance update changed data in table 'maintenances'");
$this->assertEquals($oldHashHosts, CDBHelper::getHash($sqlHosts), "Chuck Norris: Maintenance update changed data in table 'maintenances_hosts'");
$this->assertEquals($oldHashGroups, CDBHelper::getHash($sqlGroups), "Chuck Norris: Maintenance update changed data in table 'maintenances_groups'");
$this->assertEquals($oldHashWindows, CDBHelper::getHash($sqlWindows), "Chuck Norris: Maintenance update changed data in table 'maintenances_windows'");
$this->assertEquals($oldHashTimeperiods, CDBHelper::getHash($sqlTimeperiods), "Chuck Norris: Maintenance update changed data in table 'timeperiods'");
}
/**
* @dataProvider allMaintenances
* @backup maintenances
*/
public function testPageMaintenance_MassDelete($maintenance) {
$maintenanceid = $maintenance['maintenanceid'];
$this->zbxTestLogin('maintenance.php');
$this->zbxTestDropdownSelectWait('groupid', 'all');
$this->zbxTestCheckTitle('Configuration of maintenance periods');
$this->zbxTestCheckboxSelect('maintenanceids_'.$maintenanceid);
$this->zbxTestClickButton('maintenance.massdelete');
$this->zbxTestAcceptAlert();
$this->zbxTestCheckTitle('Configuration of maintenance periods');
$this->zbxTestTextPresent('Maintenance deleted');
$sql = "select * from maintenances where maintenanceid=$maintenanceid";
$this->assertEquals(0, CDBHelper::getCount($sql));
$sql = "select * from maintenances_hosts where maintenanceid=$maintenanceid";
$this->assertEquals(0, CDBHelper::getCount($sql));
$sql = "select * from maintenances_groups where maintenanceid=$maintenanceid";
$this->assertEquals(0, CDBHelper::getCount($sql));
$sql = "select * from maintenances_windows where maintenanceid=$maintenanceid";
$this->assertEquals(0, CDBHelper::getCount($sql));
$sql = "select * from timeperiods where timeperiodid in (select timeperiodid from maintenances_windows where maintenanceid=$maintenanceid)";
$this->assertEquals(0, CDBHelper::getCount($sql));
}
}
|