@@ -182,6 +182,33 @@ public function testExtractWithStringNameLooksUpFromArtifactLoader(): void
182182 $ this ->assertSame (SPC_STATUS_ALREADY_EXTRACTED , $ result );
183183 }
184184
185+ public function testExtractLocalSourceUsesLocalDirnameInPlace (): void
186+ {
187+ ApplicationContext ::initialize ();
188+
189+ // A real directory standing in for the user's local source tree.
190+ $ localDir = $ this ->tempDir . '/user-local-src ' ;
191+ mkdir ($ localDir , 0755 , true );
192+ file_put_contents ($ localDir . '/marker.txt ' , 'keep me ' );
193+
194+ $ artifact = new Artifact ('local-pkg ' , ['source ' => ['type ' => 'local ' ]]);
195+
196+ $ cache = $ this ->createMock (ArtifactCache::class);
197+ $ cache ->method ('getSourceInfo ' )->willReturn (['cache_type ' => 'local ' , 'dirname ' => $ localDir ]);
198+ $ cache ->method ('getBinaryInfo ' )->willReturn (null );
199+ $ cache ->method ('isBinaryDownloaded ' )->willReturn (false );
200+ ApplicationContext ::set (ArtifactCache::class, $ cache );
201+
202+ $ extractor = new ArtifactExtractor ($ cache , false );
203+ $ result = $ extractor ->extract ($ artifact , true ); // force_source: never pick a binary
204+
205+ // Local sources are not extracted: the tree lives in place at $cache_info['dirname'].
206+ $ this ->assertSame (SPC_STATUS_ALREADY_EXTRACTED , $ result );
207+ $ this ->assertFileExists ($ localDir . '/marker.txt ' );
208+ $ this ->assertFalse (is_link ($ localDir ));
209+ $ this ->assertSame (\StaticPHP \Util \FileSystem ::convertPath ($ localDir ), $ artifact ->getSourceDir ());
210+ }
211+
185212 // ==================== Helpers ====================
186213
187214 /**
0 commit comments