Source
'expected_error' => 'Cannot send request: discovery rule "4 LLD (0/1/1)" on host "API test task.create not monitored" is not monitored.'
<?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 __DIR__.'/../include/CAPITest.php';
/**
* @onBefore prepareItemsData
*
* @onAfter clearData
*/
class testTaskCreate extends CAPITest {
private static $data = [
'templategroupid' => null,
'hostgroupid' => null,
'hostids' => [
'monitored' => null,
'not_monitored' => null,
'template' => null
],
'itemids' => [
'not_exists' => '01'
]
];
private static $clear_taskids = [];
public function prepareItemsData() {
// Create template group.
$templategroups = CDataHelper::call('templategroup.create', [
[
'name' => 'API test task.create'
]
]);
$this->assertArrayHasKey('groupids', $templategroups);
self::$data['templategroupid'] = $templategroups['groupids'][0];
// Create host group.
$hostgroups = CDataHelper::call('hostgroup.create', [
[
'name' => 'API test task.create'
]
]);
$this->assertArrayHasKey('groupids', $hostgroups);
self::$data['hostgroupid'] = $hostgroups['groupids'][0];
// Create monitored host and not monitored host.
$hosts_data = [
[
'host' => 'api_test_task_create_monitored',