@@ -46,6 +46,7 @@ public function output_writes_nothing_for_empty_tree()
4646
4747 /**
4848 * @test
49+ *
4950 * @dataProvider controllerTreeDataProvider
5051 */
5152 public function output_writes_migration_for_controller_tree ($ definition , $ path , $ controller )
@@ -240,4 +241,31 @@ public function controllerTreeDataProvider()
240241 ['drafts/invokable-controller-shorthand.yaml ' , 'app/Http/Controllers/ReportController.php ' , 'controllers/invokable-controller-shorthand.php ' ],
241242 ];
242243 }
244+
245+ public function testOutputGeneratesControllersWithTypehints (): void
246+ {
247+ $ definition = 'drafts/controller-returns-view-typehint.yaml ' ;
248+ $ path = 'app/Http/Controllers/UserController.php ' ;
249+ $ controller = 'controllers/controller-returns-view-typehint.php ' ;
250+
251+ $ this ->app ['config ' ]->set ('blueprint.use_return_types ' , true );
252+
253+ $ this ->filesystem ->expects ('stub ' )
254+ ->with ('controller.class.stub ' )
255+ ->andReturn ($ this ->stub ('controller.class.stub ' ));
256+ $ this ->filesystem ->expects ('stub ' )
257+ ->with ('controller.method.stub ' )
258+ ->andReturn ($ this ->stub ('controller.method.stub ' ));
259+
260+ $ this ->filesystem ->expects ('exists ' )
261+ ->with (dirname ($ path ))
262+ ->andReturnTrue ();
263+ $ this ->filesystem ->expects ('put ' )
264+ ->with ($ path , $ this ->fixture ($ controller ));
265+
266+ $ tokens = $ this ->blueprint ->parse ($ this ->fixture ($ definition ));
267+ $ tree = $ this ->blueprint ->analyze ($ tokens );
268+
269+ self ::assertSame (['created ' => [$ path ]], $ this ->subject ->output ($ tree ));
270+ }
243271}
0 commit comments