fixed problems with test
Former-commit-id: 7897203e3ba020fdda8b06fd82a53d18bd91aaa1
This commit is contained in:
parent
f0c9957838
commit
a033149a2f
|
@ -158,8 +158,8 @@ class Item extends Model
|
|||
|
||||
// The item uses HTML output.
|
||||
if (static::$useHtmlOutput === true) {
|
||||
if (static::notEmptyStringOr($data['encodedHtml'], null) === null
|
||||
&& static::notEmptyStringOr($data['html'], null) === null
|
||||
if (static::notEmptyStringOr(static::issetInArray($data, ['encodedHtml']), null) === null
|
||||
&& static::notEmptyStringOr(static::issetInArray($data, ['html']), null) === null
|
||||
) {
|
||||
throw new \InvalidArgumentException(
|
||||
'the html property is required and should be a not empty string'
|
||||
|
|
|
@ -44,7 +44,7 @@ final class ColorCloud extends Item
|
|||
$decodedData['label'] = null;
|
||||
$decodedData['defaultColor'] = static::extractDefaultColor($data);
|
||||
$decodedData['colorRanges'] = static::extractColorRanges($data);
|
||||
$decodedData['color'] = static::notEmptyStringOr($data['color'], null);
|
||||
$decodedData['color'] = static::notEmptyStringOr(static::issetInArray($data, ['color']), null);
|
||||
|
||||
return $decodedData;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ final class Label extends Item
|
|||
protected function validateData(array $data): void
|
||||
{
|
||||
parent::validateData($data);
|
||||
if (static::notEmptyStringOr($data['label'], null) === null) {
|
||||
if (static::notEmptyStringOr(static::issetInArray($data, ['label']), null) === null) {
|
||||
throw new \InvalidArgumentException(
|
||||
'the label property is required and should be a not empty string'
|
||||
);
|
||||
|
|
|
@ -52,8 +52,8 @@ final class Percentile extends Item
|
|||
{
|
||||
parent::validateData($data);
|
||||
|
||||
if (static::notEmptyStringOr($data['encodedHtml'], null) === null
|
||||
&& static::notEmptyStringOr($data['html'], null) === null
|
||||
if (static::notEmptyStringOr(static::issetInArray($data, ['encodedHtml']), null) === null
|
||||
&& static::notEmptyStringOr(static::issetInArray($data, ['html']), null) === null
|
||||
) {
|
||||
throw new \InvalidArgumentException(
|
||||
'the html property is required and should be string'
|
||||
|
@ -77,7 +77,7 @@ final class Percentile extends Item
|
|||
$return['type'] = PERCENTILE_BAR;
|
||||
$return['percentileType'] = static::extractPercentileType($data);
|
||||
$return['valueType'] = static::extractValueType($data);
|
||||
$return['value'] = static::notEmptyStringOr($data['value'], null);
|
||||
$return['value'] = static::notEmptyStringOr(static::issetInArray($data, ['value']), null);
|
||||
$return['color'] = static::extractColor($data);
|
||||
$return['labelColor'] = static::extractLabelColor($data);
|
||||
return $return;
|
||||
|
|
|
@ -86,15 +86,31 @@ final class SimpleValue extends Item
|
|||
*/
|
||||
private static function extractProcessValue(array $data): string
|
||||
{
|
||||
switch ($data['processValue']) {
|
||||
case 'none':
|
||||
case 'avg':
|
||||
case 'max':
|
||||
case 'min':
|
||||
return $data['processValue'];
|
||||
if (isset($data['processValue'])) {
|
||||
switch ($data['processValue']) {
|
||||
case 'none':
|
||||
case 'avg':
|
||||
case 'max':
|
||||
case 'min':
|
||||
return $data['processValue'];
|
||||
|
||||
default:
|
||||
return 'none';
|
||||
default:
|
||||
return 'none';
|
||||
}
|
||||
} else {
|
||||
switch ($data['type']) {
|
||||
case SIMPLE_VALUE_MAX:
|
||||
return 'max';
|
||||
|
||||
case SIMPLE_VALUE_MIN:
|
||||
return 'min';
|
||||
|
||||
case SIMPLE_VALUE_AVG:
|
||||
return 'avg';
|
||||
|
||||
default:
|
||||
return 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +124,10 @@ final class SimpleValue extends Item
|
|||
*/
|
||||
private static function extractPeriod(array $data): int
|
||||
{
|
||||
$period = static::parseIntOr($data['period'], 0);
|
||||
$period = static::parseIntOr(
|
||||
static::issetInArray($data, ['period']),
|
||||
0
|
||||
);
|
||||
return ($period >= 0) ? $period : 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ final class StaticGraph extends Item
|
|||
$return['imageSrc'] = $this->extractImageSrc($data);
|
||||
$return['showLastValueTooltip'] = $this->extractShowLastValueTooltip($data);
|
||||
$return['statusImageSrc'] = static::notEmptyStringOr(
|
||||
$data['statusImageSrc'],
|
||||
static::issetInArray($data, ['statusImageSrc']),
|
||||
null
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue