Source
$this->assertEquals($data['userdb_lang'], CDBHelper::getValue('SELECT lang FROM users WHERE username='.zbx_dbstr('user-zabbix')));
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
require_once dirname(__FILE__).'/../include/CWebTest.php';
require_once dirname(__FILE__).'/behaviors/CMessageBehavior.php';
/**
* @backup users
*
* @backup config
*/
class testLanguage extends CWebTest {
private const INFO = 'You are not able to choose some of the languages, because'.
' locales for them are not installed on the web server.';
private const INFO_RUS = 'Вы не можете выбрать некоторые языки, т.к. локали для'.
' них не установлены на вашем веб-сервере.';
private const WARNING_TITLE = 'You are not logged in';
private const WARNING_TITLE_RUS = 'Вы не выполнили вход';
/**
* Attach MessageBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return [CMessageBehavior::class];
}
public static function getGuiData() {
return [
[
[
'field' => [
'Default language' => 'Russian (ru_RU)'
],
'message' => 'Configuration updated',
'page_title' => 'Настройка веб-интерфейса',
'html_lang' => 'ru',
'defaultdb_lang' => 'ru_RU',
'info' => self::INFO_RUS,
'login_info' => [
'name' => 'Имя пользователя',
'password' => 'Пароль'
]
]
],
[
[
'field' => [
'Язык по умолчанию' => 'Английский (en_US)'
],
'message' => 'Настройки обновлены',
'page_title' => 'Configuration of GUI',
'html_lang' => 'en',
'defaultdb_lang' => 'en_US',
'info' => self::INFO,
'login_info' => [
'name' => 'Username',
'password' => 'Password'
]
]
]
];
}
/**
* @dataProvider getGuiData
*/
public function testLanguage_Gui($data) {
$this->page->login();
$this->page->open('zabbix.php?action=gui.edit');
// Change default language.
$form = $this->query('xpath://form[@aria-labelledby="page-title-general"]')->one()->asForm();
$form->fill($data['field']);
$form->submit();
$this->page->waitUntilReady();
$this->checkLanguage($data['message'], $data['page_title'], $data['html_lang'], $data['defaultdb_lang']);