Source
xxxxxxxxxx
$this->assertEquals($values, $saved_form->getFields()->filter(new CElementFilter(CElementFilter::VISIBLE))->asValues());
<?php
/*
** Zabbix
** Copyright (C) 2001-2023 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__).'/../../include/CWebTest.php';
require_once dirname(__FILE__).'/../behaviors/CMessageBehavior.php';
/**
* @backup dashboard
*
* @onBefore prepareDashboardData
*
* @dataSource WebScenarios
*/
class testDashboardItemValueWidget extends CWebTest {
/**
* Attach MessageBehavior to the test.
*
* @return array
*/
public function getBehaviors() {
return [
'class' => CMessageBehavior::class
];
}
protected static $dashboardid;
protected static $old_name = 'New widget';
protected static $threshold_widget = 'Widget with thresholds';
private $sql = 'SELECT wf.widgetid, wf.type, wf.name, wf.value_int, wf.value_str, wf.value_groupid, wf.value_hostid,'.
' wf.value_itemid, wf.value_graphid, wf.value_sysmapid, w.widgetid, w.dashboard_pageid, w.type, w.name, w.x, w.y,'.
' w.width, w.height'.
' FROM widget_field wf'.
' INNER JOIN widget w'.
' ON w.widgetid=wf.widgetid ORDER BY wf.widgetid, wf.name, wf.value_int, wf.value_str, wf.value_groupid,'.
' wf.value_itemid, wf.value_graphid';
/**
* Get threshold table element with mapping set.
*
* @return CMultifieldTable
*/
protected function getThresholdTable() {
return $this->query('id:thresholds-table')->asMultifieldTable([
'mapping' => [
'' => [
'name' => 'color',
'selector' => 'class:color-picker',
'class' => 'CColorPickerElement'
],
'Threshold' => [
'name' => 'threshold',
'selector' => 'xpath:./input',
'class' => 'CElement'
]
]
])->waitUntilVisible()->one();
}
public static function prepareDashboardData() {
$response = CDataHelper::call('dashboard.create', [
[
'name' => 'Dashboard for Single Item Widget test',
'private' => 0,
'pages' => [
[
'name' => 'Page with widgets',
'widgets' => [
[
'type' => 'item',
'name' => self::$old_name,
'x' => 0,