diff --git a/pandora_console/include/rest-api/models/VisualConsole/Container.php b/pandora_console/include/rest-api/models/VisualConsole/Container.php index 7afc3ec5ba..e5c110a4bf 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Container.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Container.php @@ -142,7 +142,13 @@ final class Container extends Model private function extractBackgroundColor(array $data) { return static::notEmptyStringOr( - static::issetInArray($data, ['backgroundColor', 'background_color']), + static::issetInArray( + $data, + [ + 'backgroundColor', + 'background_color', + ] + ), null ); } @@ -158,8 +164,7 @@ final class Container extends Model private function extractFavorite(array $data): bool { return static::parseBool( - static::issetInArray($data, ['is_favourite', 'isFavorite']), - null + static::issetInArray($data, ['is_favourite', 'isFavorite']) ); } diff --git a/pandora_console/tests/Functional/Models/VisualConsole/ItemTest.php b/pandora_console/tests/Functional/Models/VisualConsole/ItemTest.php index b9f63993b3..727e4153b2 100644 --- a/pandora_console/tests/Functional/Models/VisualConsole/ItemTest.php +++ b/pandora_console/tests/Functional/Models/VisualConsole/ItemTest.php @@ -6,12 +6,17 @@ use PHPUnit\Framework\TestCase; use Models\VisualConsole\Item as ItemConsole; /** - * Test class + * Test for the Visual Console Item model. */ class ItemTest extends TestCase { + /** + * Test if the instance is created using a valid data structure. + * + * @return void + */ public function testCanBeCreatedFromValidUserStructure(): void { $this->assertInstanceOf( @@ -48,6 +53,11 @@ class ItemTest extends TestCase } + /** + * Test if the instance is not created when using a invalid id. + * + * @return void + */ public function testCannotBeCreatedWithInvalidId(): void { $this->expectException(InvalidArgumentException::class); @@ -87,6 +97,11 @@ class ItemTest extends TestCase } + /** + * Test if the instance is not created when using a invalid type. + * + * @return void + */ public function testCannotBeCreatedWithInvalidType(): void { $this->expectException(InvalidArgumentException::class); @@ -126,6 +141,11 @@ class ItemTest extends TestCase } + /** + * Test if the instance is not created when using a invalid width. + * + * @return void + */ public function testCannotBeCreatedWithInvalidWidth(): void { $this->expectException(InvalidArgumentException::class); @@ -165,6 +185,11 @@ class ItemTest extends TestCase } + /** + * Test if the instance is not created when using a invalid height. + * + * @return void + */ public function testCannotBeCreatedWithInvalidHeight(): void { $this->expectException(InvalidArgumentException::class); @@ -204,6 +229,11 @@ class ItemTest extends TestCase } + /** + * Test if the model has a valid JSON representation. + * + * @return void + */ public function testItemIsRepresentedAsJson(): void { $this->assertEquals(