mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-21 00:02:17 +02:00
Merge remote-tracking branch 'origin/support/3.2' into develop
This commit is contained in:
@@ -527,14 +527,14 @@ class ValueSetEnum extends ValueSetDefinition
|
|||||||
$aValues = [];
|
$aValues = [];
|
||||||
if (is_array($this->m_values))
|
if (is_array($this->m_values))
|
||||||
{
|
{
|
||||||
foreach ($this->m_values as $value) {
|
foreach ($this->m_values as $key => $value) {
|
||||||
// Handle backed-enum case
|
// Handle backed-enum case
|
||||||
if (is_object($value) && enum_exists(get_class($value))) {
|
if (is_object($value) && enum_exists(get_class($value))) {
|
||||||
$aValues[] = $value->value;
|
$aValues[$value->value] = $value->value;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$aValues[] = $value;
|
$aValues[$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif (is_string($this->m_values) && strlen($this->m_values) > 0)
|
elseif (is_string($this->m_values) && strlen($this->m_values) > 0)
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class ValueSetEnumTest extends ItopTestCase
|
|||||||
"c" => "c",
|
"c" => "c",
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
"Array, already ordered" => [
|
"Array without keys, already ordered" => [
|
||||||
["a", "b", "c"],
|
["a", "b", "c"],
|
||||||
[
|
[
|
||||||
0 => "a",
|
0 => "a",
|
||||||
@@ -72,12 +72,20 @@ class ValueSetEnumTest extends ItopTestCase
|
|||||||
2 => "c",
|
2 => "c",
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
"Array with keys, already ordered" => [
|
||||||
|
["a" => "a", "b" => "b", "c" => "c"],
|
||||||
|
[
|
||||||
|
"a" => "a",
|
||||||
|
"b" => "b",
|
||||||
|
"c" => "c",
|
||||||
|
],
|
||||||
|
],
|
||||||
"Backed-Enum" => [
|
"Backed-Enum" => [
|
||||||
ABCEnum::class,
|
ABCEnum::class,
|
||||||
[
|
[
|
||||||
0 => "a",
|
"a" => "a",
|
||||||
1 => "b",
|
"b" => "b",
|
||||||
2 => "c",
|
"c" => "c",
|
||||||
],
|
],
|
||||||
true, // Is the input value a backed enum?
|
true, // Is the input value a backed enum?
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user