Skip to content

Commit 1f98e7b

Browse files
authored
[make:registration-form] use route attributes for test routes (#1267)
1 parent d6eb1d8 commit 1f98e7b

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

tests/Maker/MakeRegistrationFormTest.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,9 @@ private function createRegistrationFormTest(): MakerTestDetails
3434
);
3535

3636
if (60000 > $runner->getSymfonyVersion()) {
37-
/*
38-
* @Legacy - Drop when Symfony 6.0 is LTS
39-
*
40-
* This is a round about way to handle empty yaml files and YamlSourceManipulator.
41-
* Prior to Symfony 6.0, the routes.yaml was empty w/ a comment line. YSM
42-
* requires a top level array structure to manipulate them.
43-
*/
44-
$runner->writeFile('config/routes.yaml', 'app_homepage:');
37+
// @legacy - In 5.4 tests, we need to tell Symfony to look for the route attributes in `src/Controller`
38+
$runner->copy('router-annotations.yaml', 'config/routes/annotations.yaml');
4539
}
46-
47-
$runner->modifyYamlFile('config/routes.yaml', function (array $yaml) {
48-
$yaml['app_homepage'] = ['path' => '/', 'controller' => 'App\Controller\TestingController::homepage'];
49-
$yaml['app_anonymous'] = ['path' => '/anonymous', 'controller' => 'App\Controller\TestingController::anonymous'];
50-
51-
return $yaml;
52-
});
5340
})
5441
;
5542
}

tests/fixtures/make-registration-form/standard_setup/src/Controller/TestingController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@
44

55
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
66
use Symfony\Component\HttpFoundation\Response;
7+
use Symfony\Component\Routing\Annotation\Route;
78

89
class TestingController extends AbstractController
910
{
11+
#[Route(path: '/', name: 'app_homepage')]
1012
public function homepage()
1113
{
1214
$this->denyAccessUnlessGranted('ROLE_USER');
1315

1416
return new Response('Page Success');
1517
}
1618

19+
#[Route(path: '/anonymous', name: 'app_anonymous')]
1720
public function anonymous()
1821
{
1922
return new Response('Page Success');

0 commit comments

Comments
 (0)