AnnotationClassLoaderTest.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. namespace Symfony\Tests\Component\Routing\Loader;
  10. use Symfony\Component\Routing\Loader\LoaderResolver;
  11. use Symfony\Component\Routing\Loader\AnnotationClassLoader;
  12. use Symfony\Component\Routing\Route;
  13. use Symfony\Component\Routing\RouteCollection;
  14. class AnnotationClassLoaderTest extends \PHPUnit_Framework_TestCase
  15. {
  16. protected $loader;
  17. protected function setUp()
  18. {
  19. $this->loader = $this->getMockBuilder('Symfony\Component\Routing\Loader\AnnotationClassLoader')
  20. ->disableOriginalConstructor()
  21. ->getMockForAbstractClass();
  22. }
  23. protected function tearDown()
  24. {
  25. $this->loader = null;
  26. }
  27. /**
  28. * @covers Symfony\Component\Routing\Loader\AnnotationClassLoader::supports
  29. * @dataProvider provideTestSupportsChecksResource
  30. */
  31. public function testSupportsChecksResource($resource, $expectedSupports)
  32. {
  33. $this->assertSame($expectedSupports, $this->loader->supports($resource), '->supports() returns true if the resource is loadable');
  34. }
  35. public function provideTestSupportsChecksResource()
  36. {
  37. return array(
  38. array('class', true),
  39. array('\fully\qualified\class\name', true),
  40. array('namespaced\class\without\leading\slash', true),
  41. array('ÿClassWithLegalSpecialCharacters', true),
  42. array('5', false),
  43. array('foo.foo', false),
  44. array(null, false),
  45. );
  46. }
  47. /**
  48. * @covers Symfony\Component\Routing\Loader\AnnotationClassLoader::supports
  49. */
  50. public function testSupportsChecksTypeIfSpecified()
  51. {
  52. $this->assertTrue($this->loader->supports('class', 'annotation'), '->supports() checks the resource type if specified');
  53. $this->assertFalse($this->loader->supports('class', 'foo'), '->supports() checks the resource type if specified');
  54. }
  55. }