Completed
Push — master ( fb964a...b7229e )
by Jonathan
9s
created

Psr0FindFileTest::testFindFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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