8
8
use Composer \Package \Package ;
9
9
use Composer \Package \RootPackage ;
10
10
use Composer \Util \Filesystem ;
11
- use Composer \Downloader \DownloadManager ;
12
11
use Composer \Repository \InstalledRepositoryInterface ;
13
12
use Composer \IO \IOInterface ;
14
13
@@ -22,8 +21,6 @@ class InstallerTest extends TestCase
22
21
private $ vendorDir ;
23
22
/** @var string */
24
23
private $ binDir ;
25
- /** @var DownloadManager */
26
- private $ dm ;
27
24
/** @var InstalledRepositoryInterface */
28
25
private $ repository ;
29
26
/** @var IOInterface */
@@ -35,9 +32,8 @@ public function setUp(): void
35
32
{
36
33
$ this ->fs = new Filesystem ;
37
34
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 ();
41
37
42
38
$ this ->vendorDir = realpath (sys_get_temp_dir ()) . DIRECTORY_SEPARATOR . 'baton-test-vendor ' ;
43
39
$ this ->ensureDirectoryExistsAndClear ($ this ->vendorDir );
@@ -52,16 +48,8 @@ public function setUp(): void
52
48
),
53
49
));
54
50
55
- $ this ->dm = $ this ->getMockBuilder (DownloadManager::class)
56
- ->disableOriginalConstructor ()
57
- ->getMock ();
58
- $ this ->composer ->setDownloadManager ($ this ->dm );
59
-
60
51
$ this ->repository = $ this ->getMockBuilder (InstalledRepositoryInterface::class)->getMock ();
61
52
$ this ->io = $ this ->getMockIO ();
62
-
63
- $ consumerPackage = new RootPackage ('foo/bar ' , '1.0.0 ' , '1.0.0 ' );
64
- $ this ->composer ->setPackage ($ consumerPackage );
65
53
}
66
54
67
55
public function tearDown (): void
@@ -564,10 +552,11 @@ public function testUninstallAndDeletePackageFromLocalRepo(): void
564
552
$ package = new Package ('foo ' , '1.0.0 ' , '1.0.0 ' );
565
553
566
554
$ installer = $ this ->getMockBuilder (Installer::class)
567
- ->setMethods (array ('getInstallPath ' ))
555
+ ->setMethods (array ('getInstallPath ' , ' removeCode ' ))
568
556
->setConstructorArgs (array ($ this ->io , $ this ->composer ))
569
557
->getMock ();
570
558
$ 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 ));
571
560
572
561
$ repo = $ this ->getMockBuilder (InstalledRepositoryInterface::class)->getMock ();
573
562
$ repo ->expects ($ this ->once ())->method ('hasPackage ' )->with ($ package )->will ($ this ->returnValue (true ));
0 commit comments