Psr0FindFileTest::testFindFileNotFound()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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