This repository was archived by the owner on Nov 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathArchitectureTest.php
More file actions
47 lines (39 loc) · 1.43 KB
/
ArchitectureTest.php
File metadata and controls
47 lines (39 loc) · 1.43 KB
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
47
<?php
namespace J6s\PhpArch\Tests;
use J6s\PhpArch\Component\Architecture;
use J6s\PhpArch\PhpArch;
use J6s\PhpArch\Validation\ExplicitlyAllowDependency;
use J6s\PhpArch\Validation\MustBeSelfContained;
/**
* This class is part of PHParchs own test suite that tests the library
* and is not meant to be used in projects.
*/
class ArchitectureTest extends TestCase
{
public function testArchitectureRot(): void
{
$architecture = (new Architecture())
->components([
'Component' => 'J6s\\PhpArch\\Component',
'Validation' => 'J6s\\PhpArch\\Validation',
'Exceptions' => 'J6s\\PhpArch\\Exception',
'Parser' => 'J6s\\PhpArch\\Parser',
'PHP_Core:Exception' => 'Exception'
]);
$architecture->component('Validation')->mustNotDependOn('Component');
$architecture->component('Exceptions')->mustOnlyDependOn('PHP_Core:Exception');
$architecture->component('Parser')
->mustNotDependOn('Component')
->andMustNotDependOn('Validation');
$utility = new ExplicitlyAllowDependency(
new MustBeSelfContained('J6s\\PhpArch\\Utility'),
'J6s\\PhpArch\\Utility',
'Safe\\'
);
(new PhpArch())
->fromDirectory(__DIR__ . '/../src')
->validate($utility)
->validate($architecture)
->assertHasNoErrors();
}
}