Source
$this->assertEquals(2, CDBHelper::getCount('SELECT NULL FROM sla WHERE name LIKE ('.zbx_dbstr('%'.self::$sla_with_downtimes).')'));
<?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/CWebTest.php';
require_once dirname(__FILE__).'/../behaviors/CMessageBehavior.php';
require_once dirname(__FILE__).'/../behaviors/CTableBehavior.php';
/**
* @backup sla
*
* @dataSource Services, Sla
*/
class testFormServicesSla extends CWebTest {
/**
* Attach MessageBehavior and TableBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return [
CMessageBehavior::class,
CTableBehavior::class
];
}
private static $sla_sql = 'SELECT * FROM sla ORDER BY slaid';
private static $update_sla = 'Update SLA';
private static $sla_with_downtimes = 'SLA with schedule and downtime';
private static $delete_sla = 'SLA для удаления - 頑張って';
/**
* Check SLA create form layout.
*/
public function testFormServicesSla_Layout() {
$this->page->login()->open('zabbix.php?action=sla.list');
$this->query('button:Create SLA')->waitUntilClickable()->one()->click();
$dialog = COverlayDialogElement::find()->one()->waitUntilReady();
$this->assertEquals('New SLA', $dialog->getTitle());
$form = $dialog->query('id:sla-form')->asForm()->one();
// Check tabs available in the form.
$this->assertEquals(json_encode(['SLA', 'Excluded downtimes']), json_encode($form->getTabs()));
// Check fields in SLA tab.
$default_values = [
'Name' => '',
'SLO' => '',
'Reporting period' => 'Weekly',
'Time zone' => CDateTimeHelper::getTimeZoneFormat('System default'),
'Schedule' => '24x7',
'Effective date' => date('Y-m-d'),
'Description' => '',
'Enabled' => true,
'name:service_tags[0][operator]' => 'Equals'
];
$form->checkValue($default_values);
// Note that count of available timezones may differ based on the local environment configuration.
$this->assertEquals(420, count($form->getField('Time zone')->getOptions()->asText()));
// Check that mandatory fields are marked accordingly.
foreach (['Name', 'SLO', 'Effective date', 'Service tags'] as $sla_label) {
$this->assertEquals('form-label-asterisk', $form->getLabel($sla_label)->getAttribute('class'));
}
// Check radio buttons and their labels.
$radio_buttons = [
'Reporting period' => ['Daily', 'Weekly', 'Monthly', 'Quarterly', 'Annually'],
'Schedule' => ['24x7', 'Custom']
];
foreach ($radio_buttons as $name => $labels) {
$this->assertEquals($labels, $form->getField($name)->getLabels()->asText());
}
// Check that schedule table is not visible if the 24x7 schedule is selected.