diff --git a/pandora_console/tests/Functional/Models/VisualConsole/ContainerTest.php b/pandora_console/tests/Functional/Models/VisualConsole/ContainerTest.php new file mode 100644 index 0000000000..26ee4e8cc8 --- /dev/null +++ b/pandora_console/tests/Functional/Models/VisualConsole/ContainerTest.php @@ -0,0 +1,77 @@ +assertInstanceOf( + VisualConsole::class, + VisualConsole::fromArray( + [ + 'id' => 1, + 'name' => 'foo', + ] + ) + ); + } + + + public function testCannotBeCreatedWithInvalidId(): void + { + $this->expectException(InvalidArgumentException::class); + // Invalid id. + VisualConsole::fromArray( + [ + 'id' => 'bar', + 'name' => 'foo', + ] + ); + // Missing id. + VisualConsole::fromArray( + ['name' => 'foo'] + ); + } + + + public function testCannotBeCreatedWithInvalidName(): void + { + $this->expectException(InvalidArgumentException::class); + // Invalid name. + VisualConsole::fromArray( + [ + 'id' => 1, + 'name' => '', + ] + ); + // Missing name. + VisualConsole::fromArray( + ['id' => 1] + ); + } + + + public function testUserIsRepresentedAsJson(): void + { + $this->assertEquals( + '{"id":1,"name":"foo"}', + VisualConsole::fromArray( + [ + 'id' => 1, + 'name' => 'foo', + ] + ) + ); + } + + +}