mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
Fixed Group class (VisualConsole)
Former-commit-id: 6a241cdc76935f92f99b9cc31b66acd3082571ca
This commit is contained in:
parent
205c95bcb8
commit
7d66d0b0fe
@ -218,7 +218,10 @@ class Item extends Model
|
|||||||
*/
|
*/
|
||||||
private function extractLabel(array $data)
|
private function extractLabel(array $data)
|
||||||
{
|
{
|
||||||
return static::notEmptyStringOr($data['label'], null);
|
return static::notEmptyStringOr(
|
||||||
|
static::issetInArray($data, ['label']),
|
||||||
|
null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,9 +71,9 @@ final class Group extends Item
|
|||||||
{
|
{
|
||||||
$groupId = Model::parseIntOr(
|
$groupId = Model::parseIntOr(
|
||||||
Model::issetInArray($data, ['groupId', 'id_group']),
|
Model::issetInArray($data, ['groupId', 'id_group']),
|
||||||
0
|
-1
|
||||||
);
|
);
|
||||||
if ($groupId === null) {
|
if ($groupId < 0) {
|
||||||
throw new \InvalidArgumentException(
|
throw new \InvalidArgumentException(
|
||||||
'the group Id property is required and should be integer'
|
'the group Id property is required and should be integer'
|
||||||
);
|
);
|
||||||
|
@ -62,7 +62,7 @@ class GroupTest extends TestCase
|
|||||||
'x' => -666,
|
'x' => -666,
|
||||||
'y' => 76,
|
'y' => 76,
|
||||||
'imageSrc' => '',
|
'imageSrc' => '',
|
||||||
'id_group' => 0,
|
'groupId' => 0,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// Missing imageSrc.
|
// Missing imageSrc.
|
||||||
@ -79,7 +79,7 @@ class GroupTest extends TestCase
|
|||||||
'height' => '0',
|
'height' => '0',
|
||||||
'x' => -666,
|
'x' => -666,
|
||||||
'y' => 76,
|
'y' => 76,
|
||||||
'id_group' => 0,
|
'id_group' => 11,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -129,15 +129,22 @@ class GroupTest extends TestCase
|
|||||||
public function testContainerIsRepresentedAsJson(): void
|
public function testContainerIsRepresentedAsJson(): void
|
||||||
{
|
{
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'{"id":1,"type"11,"label":null,"labelPosition":"down","isLinkEnabled":false,"isOnTop":false,"parentId":null,"aclGroupId":null,"width":0,"height":0,"x":0,"y":0,"imageSrc":"image.jpg","groupId":0}',
|
'{"id":7,"type":11,"label":null,"labelPosition":"up","isLinkEnabled":true,"isOnTop":false,"parentId":null,"aclGroupId":null,"width":0,"height":0,"x":-666,"y":76,"imageSrc":"image.jpg","groupId":12}',
|
||||||
Group::fromArray(
|
Group::fromArray(
|
||||||
[
|
[
|
||||||
'id' => 1,
|
'id' => 7,
|
||||||
'type' => GROUP_ITEM,
|
'type' => GROUP_ITEM,
|
||||||
|
'label' => null,
|
||||||
|
'labelPosition' => 'up',
|
||||||
|
'isLinkEnabled' => true,
|
||||||
|
'isOnTop' => false,
|
||||||
|
'parentId' => null,
|
||||||
'width' => '0',
|
'width' => '0',
|
||||||
'height' => '0',
|
'height' => '0',
|
||||||
|
'x' => -666,
|
||||||
|
'y' => 76,
|
||||||
'imageSrc' => 'image.jpg',
|
'imageSrc' => 'image.jpg',
|
||||||
'groupId' => 0,
|
'groupId' => 12,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user