Source
'expected_error' => 'Start time must be less than end time for excluded downtime "Mail Server upgrade" of SLA "foo".'
<?php declare(strict_types = 1);
/*
** 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 __DIR__.'/../include/CAPITest.php';
require_once __DIR__.'/../../include/classes/helpers/CArrayHelper.php';
require_once __DIR__.'/../../include/classes/helpers/CTimezoneHelper.php';
/**
* @backup sla
*/
class testSla extends CAPITest {
public static function sla_create_data_invalid(): array {
$timezone_list = '"'.implode('", "',
array_merge([ZBX_DEFAULT_TIMEZONE], array_keys(CTimezoneHelper::getList()))
).'"';
return [
'Empty array' => [
'sla' => [],
'expected_error' => 'Invalid parameter "/": cannot be empty.'
],
'Array with null' => [
'sla' => [null],
'expected_error' => 'Invalid parameter "/1": an array is expected.'
],
'Array with bool' => [
'sla' => [true],
'expected_error' => 'Invalid parameter "/1": an array is expected.'
],
'Array with int' => [
'sla' => [0],
'expected_error' => 'Invalid parameter "/1": an array is expected.'
],
'Array with empty string' => [
'sla' => [''],
'expected_error' => 'Invalid parameter "/1": an array is expected.'
],
'Name required' => [
'sla' => [[]],
'expected_error' => 'Invalid parameter "/1": the parameter "name" is missing.'
],
'Name empty' => [
'sla' => [
'name' => null
],
'expected_error' => 'Invalid parameter "/1/name": a character string is expected.'
],
'Name bool' => [
'sla' => [
'name' => true
],
'expected_error' => 'Invalid parameter "/1/name": a character string is expected.'
],
'Name int' => [
'sla' => [
'name' => 0
],
'expected_error' => 'Invalid parameter "/1/name": a character string is expected.'
],
'Name array' => [
'sla' => [
'name' => []
],
'expected_error' => 'Invalid parameter "/1/name": a character string is expected.'
],
'Name empty string' => [
'sla' => [
'name' => ''
],
'expected_error' => 'Invalid parameter "/1/name": cannot be empty.'
],