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