Source
$sql = 'SELECT macro, value, description, type FROM hostmacro WHERE macro='.zbx_dbstr($data['fields']['macro']).' ORDER BY hostmacroid DESC';
<?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__).'/../behaviors/CMacrosBehavior.php';
require_once dirname(__FILE__).'/../behaviors/CMessageBehavior.php';
require_once dirname(__FILE__).'/../../include/CLegacyWebTest.php';
/**
* Base class for Macros tests.
*/
abstract class testFormMacros extends CLegacyWebTest {
const SQL_HOSTS = 'SELECT * FROM hosts ORDER BY hostid';
const ZABBIX_SERVERS_GROUPID = 4;
protected static $hostid_remove_inherited;
protected static $macro_resolve_hostid;
/**
* Attach Behaviors to the test.
*
* @return array
*/
public function getBehaviors() {
return [
CMacrosBehavior::class,
CMessageBehavior::class
];
}
public static function getHash() {
return CDBHelper::getHash(self::SQL_HOSTS);
}
public static function getCreateMacrosData() {
return [
[
[
'expected' => TEST_GOOD,
'Name' => '1 With MACROS',
'macros' => [
[
'action' => USER_ACTION_UPDATE,
'index' => 0,
'macro' => '{$1234}',
'value' => '!@#$%^&*()_+/*',
'description' => '!@#$%^&*()_+/*'
],
[
'macro' => '{$M:regex:^[0-9a-z]}',