AnnotationClassLoaderTest.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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\AnnotationClassLoader;
  13. use Symfony\Component\Routing\Route;
  14. use Symfony\Component\Routing\RouteCollection;
  15. class AnnotationClassLoaderTest extends \PHPUnit_Framework_TestCase
  16. {
  17. protected $loader;
  18. protected function setUp()
  19. {
  20. $this->loader = $this->getMockBuilder('Symfony\Component\Routing\Loader\AnnotationClassLoader')
  21. ->disableOriginalConstructor()
  22. ->getMockForAbstractClass();
  23. }
  24. protected function tearDown()
  25. {
  26. $this->loader = null;
  27. }
  28. /**
  29. * @covers Symfony\Component\Routing\Loader\AnnotationClassLoader::supports
  30. * @dataProvider provideTestSupportsChecksResource
  31. */
  32. public function testSupportsChecksResource($resource, $expectedSupports)
  33. {
  34. $this->assertSame($expectedSupports, $this->loader->supports($resource), '->supports() returns true if the resource is loadable');
  35. }
  36. public function provideTestSupportsChecksResource()
  37. {
  38. return array(
  39. array('class', true),
  40. array('\fully\qualified\class\name', true),
  41. array('namespaced\class\without\leading\slash', true),
  42. array('ÿClassWithLegalSpecialCharacters', true),
  43. array('5', false),
  44. array('foo.foo', false),
  45. array(null, false),
  46. );
  47. }
  48. /**
  49. * @covers Symfony\Component\Routing\Loader\AnnotationClassLoader::supports
  50. */
  51. public function testSupportsChecksTypeIfSpecified()
  52. {
  53. $this->assertTrue($this->loader->supports('class', 'annotation'), '->supports() checks the resource type if specified');
  54. $this->assertFalse($this->loader->supports('class', 'foo'), '->supports() checks the resource type if specified');
  55. }
  56. }