File tree Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Original file line number Diff line number Diff line change 3
3
4
4
namespace App \Value ;
5
5
6
+ use Assert \Assert ;
7
+
6
8
class Property
7
9
{
8
10
private string $ name ;
@@ -11,6 +13,9 @@ class Property
11
13
12
14
public function __construct (string $ name , string $ type , string $ description )
13
15
{
16
+ Assert::that ($ name )
17
+ ->notBlank ();
18
+
14
19
$ this ->name = $ name ;
15
20
$ this ->type = $ type ;
16
21
$ this ->description = $ description ;
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments