1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace Symfony\Component\Routing\Tests\Loader;
13:
14: use Symfony\Component\Routing\Loader\AnnotationFileLoader;
15: use Symfony\Component\Config\FileLocator;
16: use Symfony\Component\Routing\Annotation\Route;
17:
18: class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest
19: {
20: protected $loader;
21: protected $reader;
22:
23: protected function setUp()
24: {
25: parent::setUp();
26:
27: $this->reader = $this->getReader();
28: $this->loader = new AnnotationFileLoader(new FileLocator(), $this->getClassLoader($this->reader));
29: }
30:
31: public function testLoad()
32: {
33: $this->reader->expects($this->once())->method('getClassAnnotation');
34:
35: $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php');
36: }
37:
38: 39: 40:
41: public function testLoadTraitWithClassConstant()
42: {
43: $this->reader->expects($this->never())->method('getClassAnnotation');
44:
45: $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooTrait.php');
46: }
47:
48: 49: 50:
51: public function testLoadVariadic()
52: {
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)));
57:
58: $this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/VariadicClass.php');
59: }
60:
61: public function testSupports()
62: {
63: $fixture = __DIR__.'/../Fixtures/annotated.php';
64:
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');
67:
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');
70: }
71: }
72: