Test Failed
Push — master ( bc5b04...424213 )
by Hannes
03:21
created

FilesystemResolverSpec   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 3 1
A getMatchers() 0 5 1
A it_ignores_if_unable_to_resolve() 0 5 1
A it_returns_expanded_paths() 0 5 1
A it_returns_resolved_paths() 0 5 1
A it_prepends_basepath_if_applicable() 0 6 1
A it_is_a_resolver() 0 3 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace spec\hanneskod\readmetester\Name;
6
7
use hanneskod\readmetester\Name\FilesystemResolver;
8
use hanneskod\readmetester\Name\ResolverInterface;
9
use hanneskod\readmetester\Name\NameInterface;
10
use PhpSpec\ObjectBehavior;
0 ignored issues
show
Bug introduced by
The type PhpSpec\ObjectBehavior was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Prophecy\Argument;
0 ignored issues
show
Bug introduced by
The type Prophecy\Argument was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
13
class FilesystemResolverSpec extends ObjectBehavior
14
{
15
    function it_is_initializable()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
16
    {
17
        $this->shouldHaveType(FilesystemResolver::CLASS);
0 ignored issues
show
Bug introduced by
The constant hanneskod\readmetester\N...lesystemResolver::CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
18
    }
19
20
    function it_is_a_resolver()
21
    {
22
        $this->shouldHaveType(ResolverInterface::CLASS);
0 ignored issues
show
Bug introduced by
The constant hanneskod\readmetester\N...esolverInterface::CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
23
    }
24
25
    function it_returns_resolved_paths(NameInterface $baseName, NameInterface $toResolve)
26
    {
27
        $toResolve->getShortName()->willReturn('');
28
        $toResolve->getNamespaceName()->willReturn(__FILE__);
29
        $this->resolve($baseName, $toResolve)->shouldResolveNamespaceTo(__FILE__);
30
    }
31
32
    function it_returns_expanded_paths(NameInterface $baseName, NameInterface $toResolve)
33
    {
34
        $toResolve->getShortName()->willReturn('');
35
        $toResolve->getNamespaceName()->willReturn(__DIR__ . '/../Name/FilesystemResolverSpec.php');
36
        $this->resolve($baseName, $toResolve)->shouldResolveNamespaceTo(__DIR__ . '/FilesystemResolverSpec.php');
37
    }
38
39
    function it_prepends_basepath_if_applicable(NameInterface $baseName, NameInterface $toResolve)
40
    {
41
        $toResolve->getShortName()->willReturn('');
42
        $toResolve->getNamespaceName()->willReturn('FilesystemResolverSpec.php');
43
        $baseName->getNamespaceName()->willReturn(__DIR__ . '/OtherFile.php');
44
        $this->resolve($baseName, $toResolve)->shouldResolveNamespaceTo(__DIR__ . '/FilesystemResolverSpec.php');
45
    }
46
47
    function it_ignores_if_unable_to_resolve(NameInterface $baseName, NameInterface $toResolve)
48
    {
49
        $toResolve->getNamespaceName()->willReturn('DOES-NOT-EXIST');
50
        $baseName->getNamespaceName()->willReturn(__FILE__);
51
        $this->resolve($baseName, $toResolve)->shouldReturn($toResolve);
52
    }
53
54
    public function getMatchers(): array
55
    {
56
        return [
57
            'resolveNamespaceTo' => function (NameInterface $name, string $namespace) {
58
                return $name->getNamespaceName() == $namespace;
59
            },
60
        ];
61
    }
62
}
63