sqlHashScripts = 'SELECT * FROM scripts WHERE scriptid='.$scriptid; $this->oldHashScripts = CDBHelper::getHash($this->sqlHashScripts); } private function verifyHash() { $this->assertEquals($this->oldHashScripts, CDBHelper::getHash($this->sqlHashScripts)); } public static function allScripts() { return CDBHelper::getDataProvider('SELECT scriptid,name FROM scripts'); } public function testPageAdministrationScripts_CheckLayout() { $this->zbxTestLogin('zabbix.php?action=script.list'); $this->zbxTestCheckTitle('Configuration of scripts'); $this->zbxTestCheckHeader('Scripts'); $this->zbxTestTextPresent('Displaying'); $this->zbxTestTextPresent( ['Name', 'Type', 'Execute on', 'Commands', 'User group', 'Host group', 'Host access'] ); $dbResult = DBselect('SELECT name,command FROM scripts'); while ($dbRow = DBfetch($dbResult)) { $command= str_replace('>&', '>&', $dbRow['command']); $this->zbxTestTextPresent([$dbRow['name'], $command]); } } /** * @dataProvider allScripts */ public function testPageAdministrationScripts_SimpleUpdate($script) { $this->calculateHash($script['scriptid']); $this->zbxTestLogin('zabbix.php?action=script.list'); $this->zbxTestClickLinkText($script['name']); $this->zbxTestClickWait('update'); $this->zbxTestCheckTitle('Configuration of scripts'); $this->zbxTestTextPresent('Script updated'); $this->zbxTestTextPresent($script['name']); $this->verifyHash(); } /** * @backup scripts */ public function testPageAdministrationScripts_MassDeleteAll() { $this->zbxTestLogin('zabbix.php?action=script.list'); $this->zbxTestCheckboxSelect('all_scripts'); $this->zbxTestClickButton('script.delete'); $this->zbxTestAcceptAlert(); $this->zbxTestCheckTitle('Configuration of scripts'); $this->zbxTestTextPresent('Scripts deleted'); $this->assertEquals(0, CDBHelper::getCount('SELECT NULL FROM scripts')); } /** * @dataProvider allScripts * @backupOnce scripts */ public function testPageAdministrationScripts_MassDelete($script) { $this->zbxTestLogin('zabbix.php?action=script.list'); $this->zbxTestCheckboxSelect('scriptids_'.$script['scriptid']); $this->zbxTestClickButton('script.delete'); $this->zbxTestAcceptAlert(); $this->zbxTestCheckTitle('Configuration of scripts'); $this->zbxTestTextPresent('Script deleted'); $this->assertEquals(0, CDBHelper::getCount('SELECT NULL FROM scripts WHERE scriptid='.zbx_dbstr($script['scriptid']))); } }