require_once dirname(__FILE__).'/../include/CLegacyWebTest.php';
class testFormAdministrationGeneralGUI extends CLegacyWebTest {
public static function allValues() {
return CDBHelper::getDataProvider(
'SELECT default_theme,search_limit,max_in_table,server_check_interval'.
public function testFormAdministrationGeneralGUI_CheckLayout($allValues) {
$this->zbxTestLogin('zabbix.php?action=gui.edit');
$this->query('id:page-title-general')->asPopupButton()->one()->select('GUI');
$this->zbxTestCheckTitle('Configuration of GUI');
$this->zbxTestCheckHeader('GUI');
$this->zbxTestTextPresent([
'Limit for search and filter results',
'Max count of elements to show inside table cell',
'Show warning if Zabbix server is down'
$this->zbxTestDropdownHasOptions('default_theme', ['Blue', 'Dark']);
$this->zbxTestAssertElementPresentId('search_limit');
$this->zbxTestAssertAttribute('//input[@id="search_limit"]', 'maxlength', '6');
$this->zbxTestAssertElementPresentId('max_in_table');
$this->zbxTestAssertAttribute('//input[@id="max_in_table"]','maxlength', '5');
$this->zbxTestAssertElementPresentId('server_check_interval');
$this->zbxTestAssertElementPresentId('update');
$this->assertEquals($allValues['default_theme'], $this->zbxTestGetValue('//z-select[@name="default_theme"]'));
if ($allValues['server_check_interval']) {
$this->assertTrue($this->zbxTestCheckboxSelected('server_check_interval'));
if ($allValues['server_check_interval']==0) {
$this->assertFalse($this->zbxTestCheckboxSelected('server_check_interval'));
$this->zbxTestAssertElementValue('search_limit', $allValues['search_limit']);
$this->zbxTestAssertElementValue('max_in_table', $allValues['max_in_table']);
public function testFormAdministrationGeneralGUI_ChangeTheme() {
$this->zbxTestLogin('zabbix.php?action=gui.edit');
$sql_hash = 'SELECT '.CDBHelper::getTableFields('config', ['default_theme']).' FROM config ORDER BY configid';
$old_hash = CDBHelper::getHash($sql_hash);
$this->zbxTestDropdownSelect('default_theme', 'Dark');
$this->assertEquals('dark-theme', $this->zbxTestGetValue('//z-select[@name="default_theme"]'));
$this->zbxTestClickWait('update');
$this->zbxTestTextPresent(['Configuration updated', 'GUI', 'Default theme']);
$sql = 'SELECT default_theme FROM config WHERE default_theme='.zbx_dbstr('dark-theme');
$this->assertEquals(1, CDBHelper::getCount($sql), 'Chuck Norris: "Dark" theme can not be selected as default theme: it does not exist in the DB');
$this->zbxTestDropdownSelect('default_theme', 'Blue');
$this->assertEquals('blue-theme', $this->zbxTestGetValue('//z-select[@name="default_theme"]'));
$this->zbxTestClickWait('update');