Merge branch 'ent-3733-Crear-modelos-de-los-distintos-recursos-de-la-Consola-Visual' of https://brutus.artica.lan:8081/artica/pandorafms into ent-3733-Crear-modelos-de-los-distintos-recursos-de-la-Consola-Visual

Former-commit-id: e064684c8e12e7a9cf09fad9e56eccd4e52e6fe8
This commit is contained in:
Alejandro Gallardo Escobar 2019-03-26 09:49:34 +01:00
commit ecfba2e00c
3 changed files with 22 additions and 12 deletions

View File

@ -218,7 +218,10 @@ class Item extends Model
*/
private function extractLabel(array $data)
{
return static::notEmptyStringOr($data['label'], null);
return static::notEmptyStringOr(
static::issetInArray($data, ['label']),
null
);
}

View File

@ -70,9 +70,9 @@ final class Group extends Item
{
$groupId = Model::parseIntOr(
Model::issetInArray($data, ['groupId', 'id_group']),
0
-1
);
if ($groupId === null) {
if ($groupId < 0) {
throw new \InvalidArgumentException(
'the group Id property is required and should be integer'
);

View File

@ -62,7 +62,7 @@ class GroupTest extends TestCase
'x' => -666,
'y' => 76,
'imageSrc' => '',
'id_group' => 0,
'groupId' => 0,
]
);
// Missing imageSrc.
@ -79,7 +79,7 @@ class GroupTest extends TestCase
'height' => '0',
'x' => -666,
'y' => 76,
'id_group' => 0,
'id_group' => 11,
]
);
}
@ -129,15 +129,22 @@ class GroupTest extends TestCase
public function testContainerIsRepresentedAsJson(): void
{
$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(
[
'id' => 1,
'id' => 7,
'type' => GROUP_ITEM,
'label' => null,
'labelPosition' => 'up',
'isLinkEnabled' => true,
'isOnTop' => false,
'parentId' => null,
'width' => '0',
'height' => '0',
'x' => -666,
'y' => 76,
'imageSrc' => 'image.jpg',
'groupId' => 0,
'groupId' => 12,
]
)
);