Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Apr 13, 2022
1 parent 75e5ef0 commit 72fa13d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
2 changes: 2 additions & 0 deletions tests/Composer/Installers/Test/BitrixInstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Composer\Installers\BitrixInstaller;
use Composer\Package\Package;
use Composer\Composer;
use Composer\Package\RootPackage;

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

/**
Expand Down
3 changes: 1 addition & 2 deletions tests/Composer/Installers/Test/CakePHPInstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class CakePHPInstallerTest extends TestCase
public function setUp(): void
{
$this->package = new Package('CamelCased', '1.0', '1.0');
$this->composer = new Composer();
$this->composer->setConfig(new Config(false));
$this->composer = $this->getComposer();
}

public function testInflectPackageVars(): void
Expand Down
19 changes: 4 additions & 15 deletions tests/Composer/Installers/Test/InstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Composer\Package\Package;
use Composer\Package\RootPackage;
use Composer\Util\Filesystem;
use Composer\Downloader\DownloadManager;
use Composer\Repository\InstalledRepositoryInterface;
use Composer\IO\IOInterface;

Expand All @@ -22,8 +21,6 @@ class InstallerTest extends TestCase
private $vendorDir;
/** @var string */
private $binDir;
/** @var DownloadManager */
private $dm;
/** @var InstalledRepositoryInterface */
private $repository;
/** @var IOInterface */
Expand All @@ -35,9 +32,8 @@ public function setUp(): void
{
$this->fs = new Filesystem;

$this->composer = new Composer();
$this->config = new Config();
$this->composer->setConfig($this->config);
$this->composer = $this->getComposer();
$this->config = $this->composer->getConfig();

$this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'baton-test-vendor';
$this->ensureDirectoryExistsAndClear($this->vendorDir);
Expand All @@ -52,16 +48,8 @@ public function setUp(): void
),
));

$this->dm = $this->getMockBuilder(DownloadManager::class)
->disableOriginalConstructor()
->getMock();
$this->composer->setDownloadManager($this->dm);

$this->repository = $this->getMockBuilder(InstalledRepositoryInterface::class)->getMock();
$this->io = $this->getMockIO();

$consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0');
$this->composer->setPackage($consumerPackage);
}

public function tearDown(): void
Expand Down Expand Up @@ -564,10 +552,11 @@ public function testUninstallAndDeletePackageFromLocalRepo(): void
$package = new Package('foo', '1.0.0', '1.0.0');

$installer = $this->getMockBuilder(Installer::class)
->setMethods(array('getInstallPath'))
->setMethods(array('getInstallPath', 'removeCode'))
->setConstructorArgs(array($this->io, $this->composer))
->getMock();
$installer->expects($this->atLeastOnce())->method('getInstallPath')->with($package)->will($this->returnValue(sys_get_temp_dir().'/foo'));
$installer->expects($this->atLeastOnce())->method('removeCode')->with($package)->will($this->returnValue(null));

$repo = $this->getMockBuilder(InstalledRepositoryInterface::class)->getMock();
$repo->expects($this->once())->method('hasPackage')->with($package)->will($this->returnValue(true));
Expand Down
21 changes: 21 additions & 0 deletions tests/Composer/Installers/Test/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace Composer\Installers\Test;

use Composer\Composer;
use Composer\Config;
use Composer\IO\IOInterface;
use Composer\IO\NullIO;
use Composer\Package\Version\VersionParser;
Expand All @@ -21,6 +22,9 @@
use Composer\Package\RootPackage;
use Composer\Semver\Constraint\Constraint;
use Composer\Util\Filesystem;
use Composer\Installer\InstallationManager;
use Composer\Repository\RepositoryManager;
use Composer\Downloader\DownloadManager;

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

$composer->setConfig(new Config(false));

$dm = $this->getMockBuilder(DownloadManager::class)
->disableOriginalConstructor()
->getMock();
$composer->setDownloadManager($dm);

$im = $this->getMockBuilder(InstallationManager::class)
->disableOriginalConstructor()
->getMock();
$composer->setInstallationManager($im);

$rm = $this->getMockBuilder(RepositoryManager::class)
->disableOriginalConstructor()
->getMock();
$composer->setRepositoryManager($rm);

return $composer;
}

Expand Down

0 comments on commit 72fa13d

Please sign in to comment.