Psr0FindFileTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 41
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testFindFileNotFound() 0 3 1
A testFindFile() 0 5 1
A testFindFileWithLeadingNamespaceSeparator() 0 5 1
A testFindFileFromPearLikeClassName() 0 5 1
A setUp() 0 10 1
1
<?php
2
3
namespace Doctrine\Tests\Common\Reflection;
4
5
use Doctrine\Common\Reflection\Psr0FindFile;
6
use PHPUnit\Framework\TestCase;
7
use const DIRECTORY_SEPARATOR;
8
use function sprintf;
9
use function strlen;
10
use function substr;
11
12
class Psr0FindFileTest extends TestCase
13
{
14
    /** @var Psr0FindFile */
15
    private $psr0FindFile;
16
17
    public function testFindFile() : void
18
    {
19
        $file = $this->psr0FindFile->findFile(NoParent::class);
20
21
        self::assertSame(sprintf('%s%sNoParent.php', __DIR__, DIRECTORY_SEPARATOR), $file);
22
    }
23
24
    public function testFindFileNotFound() : void
25
    {
26
        self::assertNull($this->psr0FindFile->findFile('DoesNotExist'));
27
    }
28
29
    public function testFindFileWithLeadingNamespaceSeparator() : void
30
    {
31
        $file = $this->psr0FindFile->findFile('\Doctrine\Tests\Common\Reflection\NoParent');
32
33
        self::assertSame(sprintf('%s%sNoParent.php', __DIR__, DIRECTORY_SEPARATOR), $file);
34
    }
35
36
    public function testFindFileFromPearLikeClassName() : void
37
    {
38
        $file = $this->psr0FindFile->findFile('Doctrine_Tests_Common_Reflection_NoParent');
39
40
        self::assertSame(sprintf('%s%sNoParent.php', __DIR__, DIRECTORY_SEPARATOR), $file);
41
    }
42
43
    protected function setUp() : void
44
    {
45
        $testsRoot = substr(__DIR__, 0, -strlen(__NAMESPACE__) - 1);
46
47
        $paths = [
48
            'Doctrine\\Tests' => ['Test', $testsRoot],
49
            'Doctrine_Tests' => ['Test', $testsRoot],
50
        ];
51
52
        $this->psr0FindFile = new Psr0FindFile($paths);
53
    }
54
}
55