AnnotationClassLoaderWithAnnotationsTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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\Component\Routing\Tests\Loader;
  11. use Doctrine\Common\Annotations\AnnotationReader;
  12. use Doctrine\Common\Annotations\AnnotationRegistry;
  13. use Symfony\Component\Routing\Loader\AnnotationClassLoader;
  14. use Symfony\Component\Routing\Route;
  15. class AnnotationClassLoaderWithAnnotationsTest extends AnnotationClassLoaderTestCase
  16. {
  17. protected function setUp(string $env = null): void
  18. {
  19. $reader = new AnnotationReader();
  20. $this->loader = new class($reader, $env) extends AnnotationClassLoader {
  21. protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot): void
  22. {
  23. }
  24. };
  25. if (method_exists(AnnotationRegistry::class, 'registerLoader')) {
  26. AnnotationRegistry::registerLoader('class_exists');
  27. }
  28. }
  29. public function testDefaultRouteName()
  30. {
  31. $routeCollection = $this->loader->load($this->getNamespace().'\EncodingClass');
  32. $defaultName = array_keys($routeCollection->all())[0];
  33. $this->assertSame('symfony_component_routing_tests_fixtures_annotationfixtures_encodingclass_routeàction', $defaultName);
  34. }
  35. protected function getNamespace(): string
  36. {
  37. return 'Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures';
  38. }
  39. }