AnnotationDirectoryLoaderTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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\Tests\Component\Routing\Loader;
  11. use Symfony\Component\Routing\Loader\AnnotationDirectoryLoader;
  12. use Symfony\Component\Config\FileLocator;
  13. require_once __DIR__.'/AbstractAnnotationLoaderTest.php';
  14. class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
  15. {
  16. protected $loader;
  17. protected $reader;
  18. public function setUp()
  19. {
  20. parent::setUp();
  21. $this->reader = $this->getReader();
  22. $this->loader = new AnnotationDirectoryLoader(new FileLocator(), $this->getClassLoader($this->reader));
  23. }
  24. public function testLoad()
  25. {
  26. $this->reader->expects($this->once())->method('getClassAnnotation');
  27. $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses');
  28. }
  29. /**
  30. * @covers Symfony\Component\Routing\Loader\AnnotationDirectoryLoader::supports
  31. */
  32. public function testSupports()
  33. {
  34. $fixturesDir = __DIR__.'/../Fixtures';
  35. $this->assertTrue($this->loader->supports($fixturesDir), '->supports() returns true if the resource is loadable');
  36. $this->assertFalse($this->loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
  37. $this->assertTrue($this->loader->supports($fixturesDir, 'annotation'), '->supports() checks the resource type if specified');
  38. $this->assertFalse($this->loader->supports($fixturesDir, 'foo'), '->supports() checks the resource type if specified');
  39. }
  40. }