zbxTestLogin('zabbix.php?action=gui.edit'); $this->zbxTestCheckHeader('GUI'); $this->query('id:page-title-general')->asPopupButton()->one()->select('Working time'); $this->zbxTestCheckTitle('Configuration of working time'); $this->zbxTestCheckHeader('Working time'); $this->zbxTestAssertAttribute("//input[@id='work_period']", "maxlength", 255); $this->zbxTestAssertAttribute("//input[@id='work_period']", "value", $WorkingTime['work_period']); } public function testFormAdministrationGeneralWorkperiod_SimpleUpdate() { $sqlHash = 'SELECT * FROM config ORDER BY configid'; $oldHash = CDBHelper::getHash($sqlHash); $this->zbxTestLogin('zabbix.php?action=workingtime.edit'); $this->zbxTestCheckTitle('Configuration of working time'); $this->zbxTestCheckHeader('Working time'); $this->zbxTestClickWait('update'); $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Configuration updated'); $this->assertEquals($oldHash, CDBHelper::getHash($sqlHash)); } public static function data() { return [ [ 'work_period' => 'test', 'success_expected' => TEST_BAD, 'error-msg' => 'Incorrect value for field "work_period": a time period is expected.' ], [ 'work_period' => '1-7 09:00-24:00', 'success_expected' => TEST_BAD, 'error-msg' => 'Incorrect value for field "work_period": a time period is expected.' ], [ 'work_period' => '0-7,09:00-24:00', 'success_expected' => TEST_BAD, 'error-msg' => 'Incorrect value for field "work_period": a time period is expected.' ], [ 'work_period' => '1-5,09:00-18:00,6-7,10:00-16:00', 'success_expected' => TEST_BAD, 'error-msg' => 'Incorrect value for field "work_period": a time period is expected.' ], [ 'work_period' => '1-8,09:00-24:00', 'success_expected' => TEST_BAD, 'error-msg' => 'Incorrect value for field "work_period": a time period is expected.' ], [ 'work_period' => '1-7,09:00-25:00', 'success_expected' => TEST_BAD, 'error-msg' => 'Incorrect value for field "work_period": a time period is expected.' ], [ 'work_period' => '1-7,24:00-00:00', 'success_expected' => TEST_BAD, 'error-msg' => 'Incorrect value for field "work_period": a time period is expected.' ], [ 'work_period' => '1-7,14:00-13:00', 'success_expected' => TEST_BAD, 'error-msg' => 'Incorrect value for field "work_period": a time period is expected.' ], [ 'work_period' => '1-7,25:00-26:00', 'success_expected' => TEST_BAD, 'error-msg' => 'Incorrect value for field "work_period": a time period is expected.' ], [ 'work_period' => '1-7,13:60-14:00', 'success_expected' => TEST_BAD, 'error-msg' => 'Incorrect value for field "work_period": a time period is expected.' ], [ 'work_period' => '1-7', 'success_expected' => TEST_BAD, 'error-msg' => 'Incorrect value for field "work_period": a time period is expected.' ], [ 'work_period' => '09:00-24:00', 'success_expected' => TEST_BAD, 'error-msg' => 'Incorrect value for field "work_period": a time period is expected.' ], [ 'work_period' => '', 'success_expected' => TEST_BAD, 'error-msg' => 'Incorrect value for field "work_period": a time period is expected.' ], [ 'work_period' => '{WORKING_HOURS}', 'success_expected' => TEST_BAD, 'error-msg' => 'Incorrect value for field "work_period": a time period is expected.' ], [ 'work_period' => '{$WORKING_HOURS}', 'success_expected' => TEST_GOOD, 'error-msg' => null ], [ 'work_period' => '1-5,09:00-18:00', 'success_expected' => TEST_GOOD, 'error-msg' => null ], [ 'work_period' => '1-5,09:00-18:00;5-7,12:00-16:00', 'success_expected' => TEST_GOOD, 'error-msg' => null ] ]; } /** * @dataProvider data */ public function testFormAdministrationGeneralWorkperiod_SavingWorkperiod($work_period, $expected, $msg) { $this->zbxTestLogin('zabbix.php?action=workingtime.edit'); $this->zbxTestCheckTitle('Configuration of working time'); $this->zbxTestCheckHeader('Working time'); $this->zbxTestInputType('work_period', $work_period); $this->zbxTestClickWait('update'); switch ($expected) { case TEST_GOOD: $this->zbxTestTextNotPresent('Page received incorrect data'); $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Configuration updated'); $result = DBfetch(DBselect('SELECT work_period FROM config')); $this->assertEquals($work_period, $result['work_period']); break; case TEST_BAD: $this->zbxTestWaitUntilMessageTextPresent('msg-bad', 'Cannot update configuration'); $this->zbxTestTextPresent($msg); break; } } }