2020use Symfony \UX \StimulusBundle \AssetMapper \MappedControllerAutoImport ;
2121use Symfony \UX \StimulusBundle \Ux \UxPackageReader ;
2222
23- class ControllerMapGeneratorTest extends TestCase
23+ class ControllersMapGeneratorTest extends TestCase
2424{
2525 public function testGetControllersMap ()
2626 {
@@ -41,7 +41,12 @@ public function testGetControllersMap()
4141 $ logicalPath = substr ($ path , $ assetsPosition + 1 );
4242 }
4343
44- return new MappedAsset ($ logicalPath , $ path , content: file_get_contents ($ path ));
44+ $ content = null ;
45+ if (str_ends_with ($ path , 'minified-controller.js ' )) {
46+ $ content = 'import{Controller}from"@hotwired/stimulus";export default class extends Controller{} ' ;
47+ }
48+
49+ return new MappedAsset ($ logicalPath , $ path , content: $ content );
4550 });
4651
4752 $ packageReader = new UxPackageReader (__DIR__ .'/../fixtures ' );
@@ -73,8 +78,8 @@ public function testGetControllersMap()
7378 $ map = $ generator ->getControllersMap ();
7479 // + 3 controller.json UX controllers
7580 // - 1 controllers.json UX controller is disabled
76- // + 9 custom controllers (1 file is not a controller & 1 is overridden)
77- $ this ->assertCount (11 , $ map );
81+ // + 10 custom controllers (1 file is not a controller & 1 is overridden)
82+ $ this ->assertCount (12 , $ map );
7883 $ packageNames = array_keys ($ map );
7984 sort ($ packageNames );
8085 $ this ->assertSame ([
@@ -84,6 +89,7 @@ public function testGetControllersMap()
8489 'hello ' ,
8590 'hello-with-dashes ' ,
8691 'hello-with-underscores ' ,
92+ 'minified ' ,
8793 'other ' ,
8894 'subdir--deeper ' ,
8995 'subdir--deeper-with-dashes ' ,
@@ -115,5 +121,8 @@ public function testGetControllersMap()
115121
116122 $ otherController = $ map ['other ' ];
117123 $ this ->assertTrue ($ otherController ->isLazy );
124+
125+ $ minifiedController = $ map ['minified ' ];
126+ $ this ->assertTrue ($ minifiedController ->isLazy );
118127 }
119128}
0 commit comments