Welcome to mirror list, hosted at ThFree Co, Russian Federation.

testAuditlogIconMap.php « api_json « tests « ui - github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e11c8796ad4242627123507ce01825c9d496eaf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
/*
** Zabbix
** Copyright (C) 2001-2022 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__).'/common/testAuditlogCommon.php';

/**
 * @backup icon_mapping
 */
class testAuditlogIconMap extends testAuditlogCommon {

	/**
	 * Existing Icon map ID.
	 */
	private const ICONMAPID = 1;

	public function testAuditlogIconMap_Create() {
		$create = $this->call('iconmap.create', [
			[
				'name' => 'icon_mapping',
				'default_iconid' => 5,
				'mappings' => [
					[
						'inventory_link' => 1,
						'expression' => 'created_mapping',
						'iconid' => 2
					]
				]
			]
		]);

		$resourceid = $create['result']['iconmapids'][0];
		$icon_map = CDBHelper::getRow('SELECT iconmappingid FROM icon_mapping WHERE iconmapid='.zbx_dbstr($resourceid));

		$created = json_encode([
			'iconmap.name' => ['add', 'icon_mapping'],
			'iconmap.default_iconid' => ['add', '5'],
			'iconmap.mappings['.$icon_map['iconmappingid'].']' => ['add'],
			'iconmap.mappings['.$icon_map['iconmappingid'].'].inventory_link' => ['add', '1'],
			'iconmap.mappings['.$icon_map['iconmappingid'].'].expression' => ['add', 'created_mapping'],
			'iconmap.mappings['.$icon_map['iconmappingid'].'].iconid' => ['add', '2'],
			'iconmap.mappings['.$icon_map['iconmappingid'].'].iconmappingid' => ['add', $icon_map['iconmappingid']],
			'iconmap.iconmapid' => ['add', $resourceid]
		]);

		$this->getAuditDetails('details', $this->add_actionid, $created, $resourceid);
	}

	public function testAuditlogIconMap_Update() {
		$this->call('iconmap.update', [
			[
				'iconmapid' => self::ICONMAPID,
				'name' => 'updated_icon_mapping',
				'default_iconid' => 4,
				'mappings' => [
					[
						'inventory_link' => 2,
						'expression' => 'updated_created_mapping',
						'iconid' => 3
					]
				]
			]
		]);

		$icon_map = CDBHelper::getRow('SELECT iconmappingid FROM icon_mapping WHERE iconmapid='.zbx_dbstr(self::ICONMAPID));

		$updated = json_encode([
			'iconmap.mappings[1]' => ['delete'],
			'iconmap.mappings['.$icon_map['iconmappingid'].']' => ['add'],
			'iconmap.name' => ['update', 'updated_icon_mapping', 'API icon map'],
			'iconmap.default_iconid' => ['update', '4', '2'],
			'iconmap.mappings['.$icon_map['iconmappingid'].'].inventory_link' => ['add', '2'],
			'iconmap.mappings['.$icon_map['iconmappingid'].'].expression' => ['add', 'updated_created_mapping'],
			'iconmap.mappings['.$icon_map['iconmappingid'].'].iconid' => ['add', '3'],
			'iconmap.mappings['.$icon_map['iconmappingid'].'].iconmappingid' => ['add', $icon_map['iconmappingid']]
		]);

		$this->getAuditDetails('details', $this->update_actionid, $updated, self::ICONMAPID);
	}

	public function testAuditlogIconMap_Delete() {
		$this->call('iconmap.delete', [self::ICONMAPID]);
		$this->getAuditDetails('resourcename', $this->delete_actionid, 'updated_icon_mapping', self::ICONMAPID);
	}
}