File tree 3 files changed +49
-1
lines changed
fixtures/make-controller/expected 3 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -32,8 +32,13 @@ public function getTestDetails(): \Generator
32
32
]);
33
33
34
34
$ this ->assertContainsCount ('created: ' , $ output , 1 );
35
-
36
35
$ this ->runControllerTest ($ runner , 'it_generates_a_controller.php ' );
36
+
37
+ // Ensure the generated controller matches what we expect
38
+ self ::assertSame (
39
+ expected: file_get_contents (\dirname (__DIR__ ).'/fixtures/make-controller/expected/FinalController.php ' ),
40
+ actual: file_get_contents ($ runner ->getPath ('src/Controller/FooBarController.php ' ))
41
+ );
37
42
}),
38
43
];
39
44
@@ -49,6 +54,12 @@ public function getTestDetails(): \Generator
49
54
self ::assertFileExists ($ controllerPath );
50
55
51
56
$ this ->runControllerTest ($ runner , 'it_generates_a_controller_with_twig.php ' );
57
+
58
+ // Ensure the generated controller matches what we expect
59
+ self ::assertSame (
60
+ expected: file_get_contents (\dirname (__DIR__ ).'/fixtures/make-controller/expected/FinalControllerWithTemplate.php ' ),
61
+ actual: file_get_contents ($ runner ->getPath ('src/Controller/FooTwigController.php ' ))
62
+ );
52
63
}),
53
64
];
54
65
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace App \Controller ;
4
+
5
+ use Symfony \Bundle \FrameworkBundle \Controller \AbstractController ;
6
+ use Symfony \Component \HttpFoundation \JsonResponse ;
7
+ use Symfony \Component \Routing \Attribute \Route ;
8
+
9
+ final class FooBarController extends AbstractController
10
+ {
11
+ #[Route('/foo/bar ' , name: 'app_foo_bar ' )]
12
+ public function index (): JsonResponse
13
+ {
14
+ return $ this ->json ([
15
+ 'message ' => 'Welcome to your new controller! ' ,
16
+ 'path ' => 'src/Controller/FooBarController.php ' ,
17
+ ]);
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace App \Controller ;
4
+
5
+ use Symfony \Bundle \FrameworkBundle \Controller \AbstractController ;
6
+ use Symfony \Component \HttpFoundation \Response ;
7
+ use Symfony \Component \Routing \Attribute \Route ;
8
+
9
+ final class FooTwigController extends AbstractController
10
+ {
11
+ #[Route('/foo/twig ' , name: 'app_foo_twig ' )]
12
+ public function index (): Response
13
+ {
14
+ return $ this ->render ('foo_twig/index.html.twig ' , [
15
+ 'controller_name ' => 'FooTwigController ' ,
16
+ ]);
17
+ }
18
+ }
You can’t perform that action at this time.
0 commit comments