Source
$this->checkTestOverlay($data, 'name:preprocessing['.$i.'][test]', in_array($step['type'], $this->change_types), $i);
<?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__).'/../../../include/items.inc.php';
require_once dirname(__FILE__).'/../behaviors/CPreprocessingBehavior.php';
/**
* @backup items
*/
class testFormPreprocessingTest extends CWebTest {
/**
* Attach PreprocessingBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return [CPreprocessingBehavior::class];
}
const HOST_ID = 40001; //'Simple form test host'
private static $key;
public $change_types = [
'Discard unchanged with heartbeat',
'Simple change',
'Change per second',
'Discard unchanged'
];
public static function getTestSingleStepData() {
return [
[
[
'expected' => TEST_GOOD,
'preprocessing' => [
['type' => 'Replace', 'parameter_1' => 'текст', 'parameter_2' => 'замена'],
['type' => 'Regular expression', 'parameter_1' => 'expression', 'parameter_2' => 'test output'],
['type' => 'Trim', 'parameter_1' => '1a2b3c'],
['type' => 'Right trim', 'parameter_1' => 'abc'],
['type' => 'Left trim', 'parameter_1' => 'def'],
['type' => 'XML XPath', 'parameter_1' => 'path'],
['type' => 'JSONPath', 'parameter_1' => 'path'],
['type' => 'CSV to JSON','parameter_1' => ' ', 'parameter_2' => '\\', 'parameter_3' => true],
['type' => 'XML to JSON'],
['type' => 'Custom multiplier', 'parameter_1' => '123'],
['type' => 'Simple change'],
['type' => 'Change per second'],
['type' => 'Boolean to decimal'],
['type' => 'Octal to decimal'],
['type' => 'Hexadecimal to decimal'],
['type' => 'JavaScript', 'parameter_1' => 'Test JavaScript'],
['type' => 'In range', 'parameter_1' => '-5', 'parameter_2' => '9.5'],
['type' => 'Matches regular expression', 'parameter_1' => 'expression'],
['type' => 'Does not match regular expression', 'parameter_1' => 'expression'],
['type' => 'Check for error in JSON', 'parameter_1' => 'path'],
['type' => 'Check for error in XML', 'parameter_1' => 'path'],
['type' => 'Check for error using regular expression', 'parameter_1' => 'path', 'parameter_2' => 'output'],
['type' => 'Discard unchanged'],
['type' => 'Discard unchanged with heartbeat', 'parameter_1' => '1'],
['type' => 'Prometheus pattern', 'parameter_1' => 'cpu_usage_system', 'parameter_2' => 'label',
'parameter_3' => 'label_name'],
['type' => 'Prometheus to JSON', 'parameter_1' => '']
],
'action' => 'Test'
]
],
[
[
'expected' => TEST_GOOD,
'preprocessing' => [
['type' => 'Regular expression', 'parameter_1' => '{$1}', 'parameter_2' => '{$A}'],