Skip to content

Commit 97617f2

Browse files
committed
Test AutoloadSourceLocator
1 parent 0fd3d9c commit 97617f2

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Reflection\BetterReflection\SourceLocator;
4+
5+
use PHPStan\Parser\PhpParserDecorator;
6+
use PHPStan\Testing\TestCase;
7+
use Roave\BetterReflection\Reflector\ClassReflector;
8+
use Roave\BetterReflection\Reflector\FunctionReflector;
9+
use Roave\BetterReflection\SourceLocator\Ast\Locator;
10+
use TestSingleFileSourceLocator\AFoo;
11+
12+
class AutoloadSourceLocatorTest extends TestCase
13+
{
14+
15+
public function testAutoloadEverythingInFile(): void
16+
{
17+
/** @var FunctionReflector $functionReflector */
18+
$functionReflector = null;
19+
$astLocator = new Locator(new PhpParserDecorator($this->getParser()), function () use (&$functionReflector): FunctionReflector {
20+
return $functionReflector;
21+
});
22+
$locator = new AutoloadSourceLocator($astLocator);
23+
$classReflector = new ClassReflector($locator);
24+
$functionReflector = new FunctionReflector($locator, $classReflector);
25+
$aFoo = $classReflector->reflect(AFoo::class);
26+
$this->assertSame('a.php', basename($aFoo->getFileName()));
27+
}
28+
29+
}

0 commit comments

Comments
 (0)