Visual Console Refactor: minor changes

Former-commit-id: a36d3901f79bb8342dc22e27946a2bb1798ce41c
This commit is contained in:
Alejandro Gallardo Escobar 2019-04-03 17:46:19 +02:00
parent 77ab7cad40
commit adc0f3c21b

View File

@ -6,12 +6,17 @@ use PHPUnit\Framework\TestCase;
use Models\VisualConsole\Items\StaticGraph; use Models\VisualConsole\Items\StaticGraph;
/** /**
* Test class * Test for the Visual Console static graph Item model.
*/ */
class StaticGrahpTest extends TestCase class StaticGraphTest 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(
@ -19,7 +24,7 @@ class StaticGrahpTest extends TestCase
StaticGraph::fromArray( StaticGraph::fromArray(
[ [
'id' => 345, 'id' => 345,
'type' => 1, 'type' => STATIC_GRAPH,
'label' => null, 'label' => null,
'labelPosition' => 'up', 'labelPosition' => 'up',
'isLinkEnabled' => true, 'isLinkEnabled' => true,
@ -40,7 +45,7 @@ class StaticGrahpTest extends TestCase
StaticGraph::fromArray( StaticGraph::fromArray(
[ [
'id' => 1000, 'id' => 1000,
'type' => 0, 'type' => STATIC_GRAPH,
'width' => 100, 'width' => 100,
'height' => 900, 'height' => 900,
'image' => 'test.jpg', 'image' => 'test.jpg',
@ -171,6 +176,11 @@ class StaticGrahpTest extends TestCase
} }
/**
* Test if the instance is not created when using a invalid image src.
*
* @return void
*/
public function testCannotBeCreatedWithInvalidImageSrc(): void public function testCannotBeCreatedWithInvalidImageSrc(): void
{ {
$this->expectException(InvalidArgumentException::class); $this->expectException(InvalidArgumentException::class);
@ -178,7 +188,7 @@ class StaticGrahpTest extends TestCase
StaticGraph::fromArray( StaticGraph::fromArray(
[ [
'id' => 3, 'id' => 3,
'type' => 0, 'type' => STATIC_GRAPH,
'label' => null, 'label' => null,
'isLinkEnabled' => true, 'isLinkEnabled' => true,
'isOnTop' => false, 'isOnTop' => false,
@ -191,11 +201,12 @@ class StaticGrahpTest extends TestCase
'showLastValueTooltip' => 'disabled', 'showLastValueTooltip' => 'disabled',
] ]
); );
// Missing imageSrc. // Missing imageSrc.
StaticGraph::fromArray( StaticGraph::fromArray(
[ [
'id' => 3, 'id' => 3,
'type' => 0, 'type' => STATIC_GRAPH,
'label' => null, 'label' => null,
'isLinkEnabled' => true, 'isLinkEnabled' => true,
'isOnTop' => false, 'isOnTop' => false,