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\AnnotationFileLoader;
15 use Symfony\Component\Config\FileLocator;
16 use Symfony\Component\Routing\Annotation\Route;
18 class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest
23 protected function setUp()
27 $this->reader = $this->getReader();
28 $this->loader = new AnnotationFileLoader(new FileLocator(), $this->getClassLoader($this->reader));
31 public function testLoad()
33 $this->reader->expects($this->once())->method('getClassAnnotation');
35 $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php');
41 public function testLoadTraitWithClassConstant()
43 $this->reader->expects($this->never())->method('getClassAnnotation');
45 $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooTrait.php');
51 public function testLoadVariadic()
53 $route = new Route(array('path' => '/path/to/{id}'));
54 $this->reader->expects($this->once())->method('getClassAnnotation');
55 $this->reader->expects($this->once())->method('getMethodAnnotations')
56 ->will($this->returnValue(array($route)));
58 $this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/VariadicClass.php');
61 public function testSupports()
63 $fixture = __DIR__.'/../Fixtures/annotated.php';
65 $this->assertTrue($this->loader->supports($fixture), '->supports() returns true if the resource is loadable');
66 $this->assertFalse($this->loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
68 $this->assertTrue($this->loader->supports($fixture, 'annotation'), '->supports() checks the resource type if specified');
69 $this->assertFalse($this->loader->supports($fixture, 'foo'), '->supports() checks the resource type if specified');