Source
$hintbox_text = $this->query('xpath://div[@class="overlay-dialogue wordbreak"]')->one()->waitUntilVisible()->getText();
<?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';
/**
* Base class for API tokens form function tests.
*/
class testFormApiTokens extends CWebTest {
const DELETE_TOKEN = 'Token to be deleted'; // Token for deletion.
const USER_ZABBIX_TOKEN = 'user-zabbix token'; // Token to be updated that belongs to user-zabbix.
const CANCEL_SIMPLE_UPDATE = 'Token for cancel or simple update'; // Token for cancel or simple update.
public static $update_token;
public $url;
/**
* Attach MessageBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return ['class' => CMessageBehavior::class];
}
/**
* Function that checks the layout of the API token configuration form in Administration or User settings section.
*
* @param string $source Section from which the scenario is executed.
*/
public function checkTokensFormLayout($source) {
$this->page->login()->open($this->url);
$this->page->waitUntilReady();
$this->page->assertTitle('API tokens');
$this->page->assertHeader('API tokens');
$this->query('button:Create API token')->one()->waitUntilClickable()->click();
COverlayDialogElement::find()->one()->waitUntilReady();
$form = $this->query('id:token_form')->asForm()->one();
foreach (['Name' => '64', 'Description' => '65535'] as $field_name => $maxlength) {
$field = $form->getField($field_name);
$this->assertEquals('', $field->getValue());
$this->assertEquals($maxlength, $field->getAttribute('maxlength'));
}
// Check the presence of User field and that it is empty by default if it exists.
if ($source === 'administration') {