Visual Console Refactor: docs and other minor improvements

Former-commit-id: 0b7340e06f045ad223988adfb02e40c3c16eb70f
This commit is contained in:
Alejandro Gallardo Escobar 2019-03-25 16:36:38 +01:00
parent 99463938d1
commit f78cb1ed81
2 changed files with 39 additions and 4 deletions

View File

@ -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'])
);
}

View File

@ -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(