Visual Console Refactor: added a WIP test file

Former-commit-id: b8bc3aab786a4b66cc7e2de9aa0ca7154f606f67
This commit is contained in:
Alejandro Gallardo Escobar 2019-03-18 13:35:59 +01:00
parent 862cba00de
commit 7b811fdc84
1 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,77 @@
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use Models\VisualConsole\Container as VisualConsole;
/**
* Test class
*/
class ContainerTest extends TestCase
{
public function testCanBeCreatedFromValidUserStructure(): void
{
$this->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',
]
)
);
}
}