Skip to content

Commit

Permalink
Test AutoloadSourceLocator
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed May 26, 2020
1 parent 0fd3d9c commit 97617f2
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php declare(strict_types = 1);

namespace PHPStan\Reflection\BetterReflection\SourceLocator;

use PHPStan\Parser\PhpParserDecorator;
use PHPStan\Testing\TestCase;
use Roave\BetterReflection\Reflector\ClassReflector;
use Roave\BetterReflection\Reflector\FunctionReflector;
use Roave\BetterReflection\SourceLocator\Ast\Locator;
use TestSingleFileSourceLocator\AFoo;

class AutoloadSourceLocatorTest extends TestCase
{

public function testAutoloadEverythingInFile(): void
{
/** @var FunctionReflector $functionReflector */
$functionReflector = null;
$astLocator = new Locator(new PhpParserDecorator($this->getParser()), function () use (&$functionReflector): FunctionReflector {
return $functionReflector;
});
$locator = new AutoloadSourceLocator($astLocator);
$classReflector = new ClassReflector($locator);
$functionReflector = new FunctionReflector($locator, $classReflector);
$aFoo = $classReflector->reflect(AFoo::class);
$this->assertSame('a.php', basename($aFoo->getFileName()));
}

}

0 comments on commit 97617f2

Please sign in to comment.