Skip to content

Commit 72fa13d

Browse files
committed
Fix build
1 parent 75e5ef0 commit 72fa13d

File tree

4 files changed

+28
-17
lines changed

4 files changed

+28
-17
lines changed

tests/Composer/Installers/Test/BitrixInstallerTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Composer\Installers\BitrixInstaller;
66
use Composer\Package\Package;
77
use Composer\Composer;
8+
use Composer\Package\RootPackage;
89

910
/**
1011
* Tests for the BitrixInstaller Class
@@ -22,6 +23,7 @@ class BitrixInstallerTest extends TestCase
2223
public function setUp(): void
2324
{
2425
$this->composer = new Composer();
26+
$this->composer->setPackage(new RootPackage('foo/bar', '1.0.0', '1.0.0'));
2527
}
2628

2729
/**

tests/Composer/Installers/Test/CakePHPInstallerTest.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ class CakePHPInstallerTest extends TestCase
2727
public function setUp(): void
2828
{
2929
$this->package = new Package('CamelCased', '1.0', '1.0');
30-
$this->composer = new Composer();
31-
$this->composer->setConfig(new Config(false));
30+
$this->composer = $this->getComposer();
3231
}
3332

3433
public function testInflectPackageVars(): void

tests/Composer/Installers/Test/InstallerTest.php

+4-15
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Composer\Package\Package;
99
use Composer\Package\RootPackage;
1010
use Composer\Util\Filesystem;
11-
use Composer\Downloader\DownloadManager;
1211
use Composer\Repository\InstalledRepositoryInterface;
1312
use 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));

tests/Composer/Installers/Test/TestCase.php

+21
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
namespace Composer\Installers\Test;
1414

1515
use Composer\Composer;
16+
use Composer\Config;
1617
use Composer\IO\IOInterface;
1718
use Composer\IO\NullIO;
1819
use Composer\Package\Version\VersionParser;
@@ -21,6 +22,9 @@
2122
use Composer\Package\RootPackage;
2223
use Composer\Semver\Constraint\Constraint;
2324
use Composer\Util\Filesystem;
25+
use Composer\Installer\InstallationManager;
26+
use Composer\Repository\RepositoryManager;
27+
use Composer\Downloader\DownloadManager;
2428

2529
abstract class TestCase extends \PHPUnit\Framework\TestCase
2630
{
@@ -75,6 +79,23 @@ protected function getComposer(): Composer
7579
$composer = new Composer;
7680
$composer->setPackage($pkg = new RootPackage('root/pkg', '1.0.0.0', '1.0.0'));
7781

82+
$composer->setConfig(new Config(false));
83+
84+
$dm = $this->getMockBuilder(DownloadManager::class)
85+
->disableOriginalConstructor()
86+
->getMock();
87+
$composer->setDownloadManager($dm);
88+
89+
$im = $this->getMockBuilder(InstallationManager::class)
90+
->disableOriginalConstructor()
91+
->getMock();
92+
$composer->setInstallationManager($im);
93+
94+
$rm = $this->getMockBuilder(RepositoryManager::class)
95+
->disableOriginalConstructor()
96+
->getMock();
97+
$composer->setRepositoryManager($rm);
98+
7899
return $composer;
79100
}
80101

0 commit comments

Comments
 (0)