4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Routing\Tests\Loader;
14 use Symfony\Component\Routing\Loader\AnnotationDirectoryLoader;
15 use Symfony\Component\Config\FileLocator;
17 class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
22 protected function setUp()
26 $this->reader = $this->getReader();
27 $this->loader = new AnnotationDirectoryLoader(new FileLocator(), $this->getClassLoader($this->reader));
30 public function testLoad()
32 $this->reader->expects($this->exactly(2))->method('getClassAnnotation');
35 ->expects($this->any())
36 ->method('getMethodAnnotations')
37 ->will($this->returnValue(array()))
40 $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses');
43 public function testLoadIgnoresHiddenDirectories()
45 $this->expectAnnotationsToBeReadFrom(array(
46 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass',
47 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\FooClass',
51 ->expects($this->any())
52 ->method('getMethodAnnotations')
53 ->will($this->returnValue(array()))
56 $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses');
59 public function testSupports()
61 $fixturesDir = __DIR__.'/../Fixtures';
63 $this->assertTrue($this->loader->supports($fixturesDir), '->supports() returns true if the resource is loadable');
64 $this->assertFalse($this->loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
66 $this->assertTrue($this->loader->supports($fixturesDir, 'annotation'), '->supports() checks the resource type if specified');
67 $this->assertFalse($this->loader->supports($fixturesDir, 'foo'), '->supports() checks the resource type if specified');
70 private function expectAnnotationsToBeReadFrom(array $classes)
72 $this->reader->expects($this->exactly(count($classes)))
73 ->method('getClassAnnotation')
74 ->with($this->callback(function (\ReflectionClass $class) use ($classes) {
75 return in_array($class->getName(), $classes);