Skip to content

Commit 54734a6

Browse files
committed
Bump test coverage for property VO
1 parent 1a56930 commit 54734a6

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

src/Value/Property.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
namespace App\Value;
55

6+
use Assert\Assert;
7+
68
class Property
79
{
810
private string $name;
@@ -11,6 +13,9 @@ class Property
1113

1214
public function __construct(string $name, string $type, string $description)
1315
{
16+
Assert::that($name)
17+
->notBlank();
18+
1419
$this->name = $name;
1520
$this->type = $type;
1621
$this->description = $description;

tests/Value/PropertyTest.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace App\Tests\Value;
5+
6+
use App\Value\Property;
7+
use InvalidArgumentException;
8+
use PHPUnit\Framework\TestCase;
9+
10+
/** @covers \App\Value\Property */
11+
class PropertyTest extends TestCase
12+
{
13+
const PATH = 'path/to/folder/';
14+
const NAME = 'name';
15+
const TYPE = 'int|null';
16+
const DESCRIPTION = 'Description';
17+
18+
/** @test */
19+
public function constructor_WithBlankNAME_ThrowException()
20+
{
21+
$this->expectException(InvalidArgumentException::class);
22+
new Property('', self::TYPE, self::DESCRIPTION);
23+
}
24+
25+
/** @test */
26+
public function getName_()
27+
{
28+
self::assertEquals(
29+
self::NAME,
30+
$this->createValidProperty()->getName()
31+
);
32+
}
33+
34+
/** @test */
35+
public function getType()
36+
{
37+
self::assertEquals(
38+
self::TYPE,
39+
$this->createValidProperty()->getType()
40+
);
41+
}
42+
43+
/** @test */
44+
public function getDescription()
45+
{
46+
self::assertEquals(
47+
self::DESCRIPTION,
48+
$this->createValidProperty()->getDescription()
49+
);
50+
}
51+
52+
private function createValidProperty(): Property
53+
{
54+
return new Property(self::NAME, self::TYPE, self::DESCRIPTION);
55+
}
56+
}

0 commit comments

Comments
 (0)