Source
'expected_error' => 'Invalid parameter "/2": value (hostid, name)=(50009, Valuemaps with the same names) already exists.'
<?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/CAPITest.php';
/**
* @backup valuemap
*/
class testValuemap extends CAPITest {
public static function valuemap_create() {
return [
[
'valuemap' => [
'name' => 'non existent parameter',
'valuemapid' => 4,
'mappings' => [
[
'value' => '0',
'newvalue' => 'Down'
]
]
],
'expected_error' => 'Invalid parameter "/1": unexpected parameter "valuemapid".'
],
// Check valuemap name.
[
'valuemap' => [
'mappings' => [
[
'value' => '0',
'newvalue' => 'Down'
]
]
],
'expected_error' => 'Invalid parameter "/1": the parameter "hostid" is missing.'
],
[
'valuemap' => [
'hostid' => '',
'mappings' => [
[
'value' => '0',
'newvalue' => 'Down'
]
]
],
'expected_error' => 'Invalid parameter "/1/hostid": a number is expected.'
],
[
'valuemap' => [
'hostid' => '123123123',
'name' => 'unknown hostid',
'mappings' => [
[
'value' => '0',
'newvalue' => 'Down'
]
]
],
'expected_error' => 'No permissions to referred object or it does not exist!'
],
// Check valuemap name.
[
'valuemap' => [
'hostid' => '1',
'mappings' => [
[
'value' => '0',
'newvalue' => 'Down'
]
]
],
'expected_error' => 'Invalid parameter "/1": the parameter "name" is missing.'
],
[
'valuemap' => [
'hostid' => '1',