-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathIsMappedTest.php
46 lines (37 loc) · 1.56 KB
/
IsMappedTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
declare(strict_types=1);
namespace Arkitect\Tests\Unit\Expressions\ForClasses;
use Arkitect\Analyzer\ClassDescriptionBuilder;
use Arkitect\Expression\ForClasses\IsMapped;
use Arkitect\Rules\Violations;
use PHPUnit\Framework\TestCase;
final class IsMappedTest extends TestCase
{
public function test_it_should_not_add_violation_if_fqcn_is_in_list(): void
{
$listedFqcn = 'App\SharedKernel\Component\MyClass';
$list = [
'a' => $listedFqcn,
'b' => 'App\SharedKernel\Component\MyOtherClass',
];
$expression = new IsMapped($list);
$classDescription = (new ClassDescriptionBuilder())->setClassName($listedFqcn)->build();
$violations = new Violations();
$expression->evaluate($classDescription, $violations, '');
self::assertEquals(0, $violations->count());
}
public function test_it_should_add_violation_if_fqcn_is_not_in_list(): void
{
$nonListedFqcn = 'App\SharedKernel\Component\MyClass';
$list = [
'a' => 'App\SharedKernel\Component\SomeClass',
'b' => 'App\SharedKernel\Component\MyOtherClass',
];
$expression = new IsMapped($list);
$classDescription = (new ClassDescriptionBuilder())->setClassName($nonListedFqcn)->build();
$violations = new Violations();
$expression->evaluate($classDescription, $violations, '');
self::assertEquals(1, $violations->count());
self::assertEquals(IsMapped::POSITIVE_DESCRIPTION, $expression->describe($classDescription, '')->toString());
}
}