zbxTestLogin('zabbix.php?action=maintenance.list'); $this->query('button:Reset')->one()->click(); $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) { $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('zabbix.php?action=maintenance.list'); $this->query('button:Reset')->one()->click(); $this->zbxTestCheckTitle('Configuration of maintenance periods'); $this->zbxTestClickLinkText($name); $this->zbxTestClickXpathWait('//button[text()="Update"]'); CMessageElement::find()->waitUntilVisible()->one(); $this->zbxTestCheckTitle('Configuration of maintenance periods'); $this->zbxTestTextPresent('Maintenance period 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 * @backupOnce maintenances */ public function testPageMaintenance_MassDelete($maintenance) { $maintenanceid = $maintenance['maintenanceid']; $this->zbxTestLogin('zabbix.php?action=maintenance.list'); $this->query('button:Reset')->one()->click(); $this->zbxTestCheckTitle('Configuration of maintenance periods'); $this->zbxTestCheckboxSelect('maintenanceids_'.$maintenanceid); $this->zbxTestClickXpathWait('//button[text()="Delete"]'); $this->zbxTestAcceptAlert(); $this->zbxTestCheckTitle('Configuration of maintenance periods'); CMessageElement::find()->waitUntilVisible()->one(); $this->zbxTestTextPresent('Maintenance period 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)); } }