AnnotationFileLoaderTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Routing\Tests\Loader;
  11. use Symfony\Component\Routing\Loader\AnnotationFileLoader;
  12. use Symfony\Component\Config\FileLocator;
  13. class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest
  14. {
  15. protected $loader;
  16. protected $reader;
  17. protected function setUp()
  18. {
  19. parent::setUp();
  20. $this->reader = $this->getReader();
  21. $this->loader = new AnnotationFileLoader(new FileLocator(), $this->getClassLoader($this->reader));
  22. }
  23. public function testLoad()
  24. {
  25. $this->reader->expects($this->once())->method('getClassAnnotation');
  26. $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php');
  27. }
  28. public function testSupports()
  29. {
  30. $fixture = __DIR__.'/../Fixtures/annotated.php';
  31. $this->assertTrue($this->loader->supports($fixture), '->supports() returns true if the resource is loadable');
  32. $this->assertFalse($this->loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
  33. $this->assertTrue($this->loader->supports($fixture, 'annotation'), '->supports() checks the resource type if specified');
  34. $this->assertFalse($this->loader->supports($fixture, 'foo'), '->supports() checks the resource type if specified');
  35. }
  36. }