File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,9 @@ public function preAutoloadDump(Event $event): void
6565
6666 $ root = dirname (realpath ($ event ->getComposer ()->getConfig ()->get ('vendor-dir ' ))) . '/ ' ;
6767 foreach ($ extra ['plugin-paths ' ] as $ pluginsPath ) {
68+ if (!is_dir ($ root . $ pluginsPath )) {
69+ continue ;
70+ }
6871 foreach (new DirectoryIterator ($ root . $ pluginsPath ) as $ fileInfo ) {
6972 if (!$ fileInfo ->isDir () || $ fileInfo ->isDot ()) {
7073 continue ;
Original file line number Diff line number Diff line change @@ -163,6 +163,45 @@ public function testPreAutoloadDump()
163163 $ this ->assertEquals ($ expected , $ package ->getDevAutoload ());
164164 }
165165
166+ public function testPreAutoloadDumpNonExistentPluginPaths ()
167+ {
168+ $ package = new RootPackage ('App ' , '1.0.0 ' , '1.0.0 ' );
169+ $ package ->setExtra ([
170+ 'plugin-paths ' => [
171+ 'unknown_folder ' ,
172+ ],
173+ ]);
174+ $ package ->setAutoload ([
175+ 'psr-4 ' => [
176+ 'Foo \\' => 'xyz/Foo/src ' ,
177+ ],
178+ ]);
179+ $ package ->setDevAutoload ([
180+ 'psr-4 ' => [
181+ 'Foo\Test \\' => 'xyz/Foo/tests ' ,
182+ ],
183+ ]);
184+ $ this ->composer ->setPackage ($ package );
185+
186+ $ event = new Event ('' , $ this ->composer , $ this ->io );
187+
188+ $ this ->plugin ->preAutoloadDump ($ event );
189+
190+ $ expected = [
191+ 'psr-4 ' => [
192+ 'Foo \\' => 'xyz/Foo/src ' ,
193+ ],
194+ ];
195+ $ this ->assertEquals ($ expected , $ package ->getAutoload ());
196+
197+ $ expected = [
198+ 'psr-4 ' => [
199+ 'Foo\Test \\' => 'xyz/Foo/tests ' ,
200+ ],
201+ ];
202+ $ this ->assertEquals ($ expected , $ package ->getDevAutoload ());
203+ }
204+
166205 public function testGetPrimaryNamespace ()
167206 {
168207 $ autoload = [
You can’t perform that action at this time.
0 commit comments