Source
$this->assertScreenshot($mapping_form->query('id:mappings_table')->waitUntilVisible()->one(), 'Value mapping mass update');
<?php
/*
** Zabbix
** 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 General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
require_once dirname(__FILE__).'/../../include/CWebTest.php';
require_once dirname(__FILE__).'/../behaviors/CMessageBehavior.php';
require_once dirname(__FILE__).'/../behaviors/CTableBehavior.php';
require_once dirname(__FILE__).'/../../include/helpers/CDataHelper.php';
/**
* Base class for Value mappings function tests.
*/
class testFormValueMappings extends CWebTest {
/**
* Attach MessageBehavior and TableBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return [
CMessageBehavior::class,
CTableBehavior::class
];
}
const HOSTID = 99134; // ID of the host for valuemap update.
const TEMPLATEID = 40000; // ID of the template for valuemap update.
const UPDATE_VALUEMAP1 = 'Valuemap for update 1';
const UPDATE_VALUEMAP2 = 'Valuemap for update 2';
const DELETE_VALUEMAP = 'Valuemap for delete';
const EXISTING_VALUEMAPS = [
[
'Name' => 'Valuemap for delete',
'Value' => "=1010101010101010101010101010101\n⇒\ndefault value1010101010101010101010101010101".
"\n424242424242424242424242424242424242424242424242\n⇒\nAnswer to the Ultimate Question of Life, ".
"Universe and Everything\n123458945-987653341\n⇒\nfrom 123458945 to 987653341\n…",
'Action' => 'Remove'
],
[
'Name' => 'Valuemap for update 1',
'Value' => "=\n⇒\nreference newvalue",
'Action' => 'Remove'
],
[
'Name' => 'Valuemap for update 2',
'Value' => "=\n⇒\nno data\n=1\n⇒\none\n=2\n⇒\ntwo\n…",
'Action' => 'Remove'
]
];
private static $previous_valuemap_name = self::UPDATE_VALUEMAP1;
private static $previous_class = null;
/**
* Function that checks the layout of the Value mappings tab in Host or Template configuration forms.
*
* @param string $source Entity (host or template) for which the scenario is executed.
*/
public function checkLayout($source) {
// Open value mapping tab.
$this->openValueMappingTab($source);
// Check value mapping table headers and content.
$table = $this->query('id:valuemap-table')->asTable()->one();
$this->assertEquals(['Name', 'Value', 'Action'], $table->getHeadersText());
$this->assertTableData(self::EXISTING_VALUEMAPS, 'id:valuemap-formlist');
// Check value mapping configuration form layout.
$this->query('name:valuemap_add')->one()->click();
$dialog = COverlayDialogElement::find()->waitUntilReady()->one();
$this->assertEquals('Value mapping', $dialog->getTitle());
$mapping_form = $dialog->getContent()->asForm();