File tree Expand file tree Collapse file tree 3 files changed +91
-0
lines changed Expand file tree Collapse file tree 3 files changed +91
-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 Diff
7
9
{
8
10
private string $ before ;
9
11
private string $ after ;
10
12
11
13
public function __construct (string $ before , string $ after )
12
14
{
15
+ Assert::thatAll ([$ before , $ after ])
16
+ ->notBlank ();
17
+
13
18
$ this ->before = $ before ;
14
19
$ this ->after = $ after ;
15
20
}
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 \Diff ;
7
+ use InvalidArgumentException ;
8
+ use PHPUnit \Framework \TestCase ;
9
+
10
+ /** @covers \App\Value\Diff */
11
+ class DiffTest extends TestCase
12
+ {
13
+ const BEFORE = 'a(); ' ;
14
+ const AFTER = 'b(); ' ;
15
+
16
+ /** @test */
17
+ public function constructor_WithEmptyValues_ThrowException ()
18
+ {
19
+ $ this ->expectException (InvalidArgumentException::class);
20
+ new Diff ('' , '' );
21
+ }
22
+
23
+ /** @test */
24
+ public function getBefore ()
25
+ {
26
+ self ::assertEquals (
27
+ self ::BEFORE ,
28
+ $ this ->createValidDiff ()->getBefore (),
29
+ );
30
+ }
31
+
32
+ /** @test */
33
+ public function getAfter ()
34
+ {
35
+ self ::assertEquals (
36
+ self ::AFTER ,
37
+ $ this ->createValidDiff ()->getAfter (),
38
+ );
39
+ }
40
+
41
+ /**
42
+ * @return Diff
43
+ */
44
+ private function createValidDiff (): Diff
45
+ {
46
+ return new Diff (self ::BEFORE , self ::AFTER );
47
+ }
48
+ }
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 \Folder ;
7
+ use InvalidArgumentException ;
8
+ use PHPUnit \Framework \TestCase ;
9
+
10
+ /** @covers \App\Value\Folder */
11
+ class FolderTest extends TestCase
12
+ {
13
+ const PATH = 'path/to/folder/ ' ;
14
+
15
+ /** @test */
16
+ public function constructor_WithMissingBackslash_ThrowException ()
17
+ {
18
+ $ this ->expectException (InvalidArgumentException::class);
19
+ new Folder ('path/to/folder ' );
20
+ }
21
+
22
+ /** @test */
23
+ public function getPath ()
24
+ {
25
+ self ::assertEquals (
26
+ self ::PATH ,
27
+ (string )$ this ->createValidFolder ()
28
+ );
29
+ }
30
+
31
+ /**
32
+ * @return Folder
33
+ */
34
+ private function createValidFolder (): Folder
35
+ {
36
+ return new Folder (self ::PATH );
37
+ }
38
+ }
You can’t perform that action at this time.
0 commit comments