Skip to content

Commit 9c85a83

Browse files
authored
minor #1565 [make:controller] add tests to confirm twig templates generated
1 parent 9060cd1 commit 9c85a83

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/Resources/help/MakeController.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ The <info>%command.name%</info> command generates a new controller class.
44

55
If the argument is missing, the command will ask for the controller class name interactively.
66

7+
If you have the <info>symfony/twig-bundle</info> installed, a Twig template will also be
8+
generated for the controller.
9+
10+
<info>composer require symfony/twig-bundle</info>
11+
712
You can also generate the controller alone, without template with this option:
813

914
<info>php %command.full_name% --no-template</info>

tests/Maker/MakeControllerTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public function getTestDetails(): \Generator
4545
'FooTwig',
4646
]);
4747

48+
$controllerPath = $runner->getPath('templates/foo_twig/index.html.twig');
49+
self::assertFileExists($controllerPath);
50+
4851
$this->runControllerTest($runner, 'it_generates_a_controller_with_twig.php');
4952
}),
5053
];
@@ -59,6 +62,9 @@ public function getTestDetails(): \Generator
5962
'FooTwig',
6063
]);
6164

65+
$controllerPath = $runner->getPath('templates/foo_twig/index.html.twig');
66+
self::assertFileExists($controllerPath);
67+
6268
$this->runControllerTest($runner, 'it_generates_a_controller_with_twig.php');
6369
}),
6470
];
@@ -100,6 +106,9 @@ public function getTestDetails(): \Generator
100106
'Admin\\FooBar',
101107
]);
102108

109+
$controllerPath = $runner->getPath('templates/admin/foo_bar/index.html.twig');
110+
self::assertFileExists($controllerPath);
111+
103112
$this->assertFileExists($runner->getPath('templates/admin/foo_bar/index.html.twig'));
104113
}),
105114
];
@@ -112,6 +121,9 @@ public function getTestDetails(): \Generator
112121
'\App\Foo\Bar\CoolController',
113122
]);
114123

124+
$controllerPath = $runner->getPath('templates/foo/bar/cool/index.html.twig');
125+
self::assertFileExists($controllerPath);
126+
115127
$this->assertStringContainsString('src/Foo/Bar/CoolController.php', $output);
116128
$this->assertStringContainsString('templates/foo/bar/cool/index.html.twig', $output);
117129
}),
@@ -125,6 +137,9 @@ public function getTestDetails(): \Generator
125137
'FooInvokable',
126138
], '--invokable');
127139

140+
$controllerPath = $runner->getPath('templates/foo_invokable.html.twig');
141+
self::assertFileExists($controllerPath);
142+
128143
$this->assertStringContainsString('src/Controller/FooInvokableController.php', $output);
129144
$this->assertStringContainsString('templates/foo_invokable.html.twig', $output);
130145
$this->runControllerTest($runner, 'it_generates_an_invokable_controller.php');
@@ -139,6 +154,9 @@ public function getTestDetails(): \Generator
139154
'Admin\\FooInvokable',
140155
], '--invokable');
141156

157+
$controllerPath = $runner->getPath('templates/admin/foo_invokable.html.twig');
158+
self::assertFileExists($controllerPath);
159+
142160
$this->assertStringContainsString('src/Controller/Admin/FooInvokableController.php', $output);
143161
$this->assertStringContainsString('templates/admin/foo_invokable.html.twig', $output);
144162
}),

0 commit comments

Comments
 (0)