mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
Visual Console Refactor: docs and other minor improvements
Former-commit-id: 0b7340e06f045ad223988adfb02e40c3c16eb70f
This commit is contained in:
parent
99463938d1
commit
f78cb1ed81
@ -142,7 +142,13 @@ final class Container extends Model
|
|||||||
private function extractBackgroundColor(array $data)
|
private function extractBackgroundColor(array $data)
|
||||||
{
|
{
|
||||||
return static::notEmptyStringOr(
|
return static::notEmptyStringOr(
|
||||||
static::issetInArray($data, ['backgroundColor', 'background_color']),
|
static::issetInArray(
|
||||||
|
$data,
|
||||||
|
[
|
||||||
|
'backgroundColor',
|
||||||
|
'background_color',
|
||||||
|
]
|
||||||
|
),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -158,8 +164,7 @@ final class Container extends Model
|
|||||||
private function extractFavorite(array $data): bool
|
private function extractFavorite(array $data): bool
|
||||||
{
|
{
|
||||||
return static::parseBool(
|
return static::parseBool(
|
||||||
static::issetInArray($data, ['is_favourite', 'isFavorite']),
|
static::issetInArray($data, ['is_favourite', 'isFavorite'])
|
||||||
null
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,12 +6,17 @@ use PHPUnit\Framework\TestCase;
|
|||||||
use Models\VisualConsole\Item as ItemConsole;
|
use Models\VisualConsole\Item as ItemConsole;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class
|
* Test for the Visual Console Item model.
|
||||||
*/
|
*/
|
||||||
class ItemTest extends TestCase
|
class ItemTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if the instance is created using a valid data structure.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function testCanBeCreatedFromValidUserStructure(): void
|
public function testCanBeCreatedFromValidUserStructure(): void
|
||||||
{
|
{
|
||||||
$this->assertInstanceOf(
|
$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
|
public function testCannotBeCreatedWithInvalidId(): void
|
||||||
{
|
{
|
||||||
$this->expectException(InvalidArgumentException::class);
|
$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
|
public function testCannotBeCreatedWithInvalidType(): void
|
||||||
{
|
{
|
||||||
$this->expectException(InvalidArgumentException::class);
|
$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
|
public function testCannotBeCreatedWithInvalidWidth(): void
|
||||||
{
|
{
|
||||||
$this->expectException(InvalidArgumentException::class);
|
$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
|
public function testCannotBeCreatedWithInvalidHeight(): void
|
||||||
{
|
{
|
||||||
$this->expectException(InvalidArgumentException::class);
|
$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
|
public function testItemIsRepresentedAsJson(): void
|
||||||
{
|
{
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user