Skip to content

Commit 1a56930

Browse files
committed
Bump test coverage for diff and folder VOs
1 parent 6df7193 commit 1a56930

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed

src/Value/Diff.php

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

44
namespace App\Value;
55

6+
use Assert\Assert;
7+
68
class Diff
79
{
810
private string $before;
911
private string $after;
1012

1113
public function __construct(string $before, string $after)
1214
{
15+
Assert::thatAll([$before, $after])
16+
->notBlank();
17+
1318
$this->before = $before;
1419
$this->after = $after;
1520
}

tests/Value/DiffTest.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
}

tests/Value/FolderTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
}

0 commit comments

Comments
 (0)