88use Composer \Package \Package ;
99use Composer \Package \RootPackage ;
1010use Composer \Util \Filesystem ;
11- use Composer \Downloader \DownloadManager ;
1211use Composer \Repository \InstalledRepositoryInterface ;
1312use Composer \IO \IOInterface ;
1413
@@ -22,8 +21,6 @@ class InstallerTest extends TestCase
2221 private $ vendorDir ;
2322 /** @var string */
2423 private $ binDir ;
25- /** @var DownloadManager */
26- private $ dm ;
2724 /** @var InstalledRepositoryInterface */
2825 private $ repository ;
2926 /** @var IOInterface */
@@ -35,9 +32,8 @@ public function setUp(): void
3532 {
3633 $ this ->fs = new Filesystem ;
3734
38- $ this ->composer = new Composer ();
39- $ this ->config = new Config ();
40- $ this ->composer ->setConfig ($ this ->config );
35+ $ this ->composer = $ this ->getComposer ();
36+ $ this ->config = $ this ->composer ->getConfig ();
4137
4238 $ this ->vendorDir = realpath (sys_get_temp_dir ()) . DIRECTORY_SEPARATOR . 'baton-test-vendor ' ;
4339 $ this ->ensureDirectoryExistsAndClear ($ this ->vendorDir );
@@ -52,16 +48,8 @@ public function setUp(): void
5248 ),
5349 ));
5450
55- $ this ->dm = $ this ->getMockBuilder (DownloadManager::class)
56- ->disableOriginalConstructor ()
57- ->getMock ();
58- $ this ->composer ->setDownloadManager ($ this ->dm );
59-
6051 $ this ->repository = $ this ->getMockBuilder (InstalledRepositoryInterface::class)->getMock ();
6152 $ this ->io = $ this ->getMockIO ();
62-
63- $ consumerPackage = new RootPackage ('foo/bar ' , '1.0.0 ' , '1.0.0 ' );
64- $ this ->composer ->setPackage ($ consumerPackage );
6553 }
6654
6755 public function tearDown (): void
@@ -564,10 +552,11 @@ public function testUninstallAndDeletePackageFromLocalRepo(): void
564552 $ package = new Package ('foo ' , '1.0.0 ' , '1.0.0 ' );
565553
566554 $ installer = $ this ->getMockBuilder (Installer::class)
567- ->setMethods (array ('getInstallPath ' ))
555+ ->setMethods (array ('getInstallPath ' , ' removeCode ' ))
568556 ->setConstructorArgs (array ($ this ->io , $ this ->composer ))
569557 ->getMock ();
570558 $ installer ->expects ($ this ->atLeastOnce ())->method ('getInstallPath ' )->with ($ package )->will ($ this ->returnValue (sys_get_temp_dir ().'/foo ' ));
559+ $ installer ->expects ($ this ->atLeastOnce ())->method ('removeCode ' )->with ($ package )->will ($ this ->returnValue (null ));
571560
572561 $ repo = $ this ->getMockBuilder (InstalledRepositoryInterface::class)->getMock ();
573562 $ repo ->expects ($ this ->once ())->method ('hasPackage ' )->with ($ package )->will ($ this ->returnValue (true ));
0 commit comments