From 7b811fdc84c4bafed2afe306b973561af1a3629b Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Mon, 18 Mar 2019 13:35:59 +0100 Subject: [PATCH] Visual Console Refactor: added a WIP test file Former-commit-id: b8bc3aab786a4b66cc7e2de9aa0ca7154f606f67 --- .../Models/VisualConsole/ContainerTest.php | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 pandora_console/tests/Functional/Models/VisualConsole/ContainerTest.php 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', + ] + ) + ); + } + + +}