AnnotationDirectoryLoaderTest.php 1.7 KB

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