LayerTest::testDomainDoesNotDependOnOtherLayers()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 10
1
<?php
2
3
namespace Tools\Phpat;
4
5
use PHPat\Selector\Selector;
6
use PHPat\Test\Builder\Rule;
7
use PHPat\Test\PHPat;
8
9
final class LayerTest
10
{
11
    private const DOMAIN_NAMESPACE = 'DaveLiddament\StaticAnalysisResultsBaseliner\Domain';
12
    private const PLUGIN_NAMESPACE = 'DaveLiddament\StaticAnalysisResultsBaseliner\Plugins';
13
    private const LEGACY_NAMESPACE = 'DaveLiddament\StaticAnalysisResultsBaseliner\Legacy';
14
    private const FRAMEWORK_NAMESPACE = 'DaveLiddament\StaticAnalysisResultsBaseliner\Framework';
15
16
    public function testDomainDoesNotDependOnOtherLayers(): Rule
17
    {
18
        return PHPat::rule()
19
            ->classes(Selector::inNamespace(self::DOMAIN_NAMESPACE))
20
            ->shouldNotDependOn()
21
            ->classes(
22
                Selector::inNamespace(self::PLUGIN_NAMESPACE),
23
                Selector::inNamespace(self::LEGACY_NAMESPACE),
24
                Selector::inNamespace(self::FRAMEWORK_NAMESPACE),
25
            )->because('Domain code should not depend on any other code')
26
        ;
27
    }
28
29
    public function testsPluginDoesNotDependOnFrameworkLayer(): Rule
30
    {
31
        return PHPat::rule()
32
            ->classes(Selector::inNamespace(self::PLUGIN_NAMESPACE))
33
            ->shouldNotDependOn()
34
            ->classes(
35
                Selector::inNamespace(self::FRAMEWORK_NAMESPACE),
36
                Selector::inNamespace(self::LEGACY_NAMESPACE),
37
            )->because('Plugin code should not depend on framework or legacy code')
38
        ;
39
    }
40
41
    public function testsLegacyDoesNotDependOnFrameworkLayer(): Rule
42
    {
43
        return PHPat::rule()
44
            ->classes(Selector::inNamespace(self::LEGACY_NAMESPACE))
45
            ->shouldNotDependOn()
46
            ->classes(
47
                Selector::inNamespace(self::FRAMEWORK_NAMESPACE),
48
            )->because('Legacy code should not depend on framework code')
49
        ;
50
    }
51
}
52