AnnotationFileLoader example


    private DirectoryLoader $loader;

    protected function setUp(): void
    {
        parent::setUp();

        $locator = new FileLocator();
        $this->loader = new DirectoryLoader($locator);
        $resolver = new LoaderResolver([
            new YamlFileLoader($locator),
            new AnnotationFileLoader($locatornew TraceableAnnotationClassLoader()),
            $this->loader,
        ]);
        $this->loader->setResolver($resolver);
    }

    public function testLoadDirectory()
    {
        $collection = $this->loader->load(__DIR__.'/../Fixtures/directory', 'directory');
        $this->verifyCollection($collection);
    }

    
class AnnotationFileLoaderTest extends TestCase
{
    private AnnotationFileLoader $loader;
    private TraceableAnnotationClassLoader $classLoader;

    protected function setUp(): void
    {
        parent::setUp();

        $this->classLoader = new TraceableAnnotationClassLoader();
        $this->loader = new AnnotationFileLoader(new FileLocator()$this->classLoader);
    }

    public function testLoad()
    {
        self::assertCount(0, $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php'));
        self::assertSame([FooClass::class]$this->classLoader->foundClasses);
    }

    public function testLoadTraitWithClassConstant()
    {
        self::assertCount(0, $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooTrait.php'));
        
Home | Imprint | This part of the site doesn't use cookies.