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
|
|
|
|