Source
xxxxxxxxxx
'expected_error' => 'Start time must be less than end time for excluded downtime "Mail Server upgrade" of SLA "foo".'
<?php declare(strict_types = 1);
/*
** 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';
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.'
],
'Name too long' => [
'sla' => [
'name' => str_repeat('a', DB::getFieldLength('sla', 'name') + 1)
],
'expected_error' => 'Invalid parameter "/1/name": value is too long.'