2022-02-23 15:58:18 +00:00
|
|
|
<?php declare(strict_types=1);
|
2017-03-08 14:07:29 +00:00
|
|
|
|
2012-05-13 19:40:42 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Composer.
|
|
|
|
*
|
|
|
|
* (c) Nils Adermann <naderman@naderman.de>
|
|
|
|
* Jordi Boggiano <j.boggiano@seld.be>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Composer\Test\Mock;
|
|
|
|
|
2022-02-18 10:22:01 +00:00
|
|
|
use Composer\Installer\InstallationManager;
|
|
|
|
use Composer\Package\Loader\RootPackageLoader;
|
2012-05-13 19:40:42 +00:00
|
|
|
use Composer\Config;
|
|
|
|
use Composer\Factory;
|
2022-02-18 13:45:08 +00:00
|
|
|
use Composer\PartialComposer;
|
2012-05-13 19:40:42 +00:00
|
|
|
use Composer\Repository\RepositoryManager;
|
2020-06-19 15:56:13 +00:00
|
|
|
use Composer\Package\Version\VersionGuesser;
|
|
|
|
use Composer\Package\Version\VersionParser;
|
2020-04-19 14:00:21 +00:00
|
|
|
use Composer\Package\RootPackageInterface;
|
2019-11-14 14:20:50 +00:00
|
|
|
use Composer\EventDispatcher\EventDispatcher;
|
2012-05-13 19:40:42 +00:00
|
|
|
use Composer\IO\IOInterface;
|
2021-08-21 15:41:52 +00:00
|
|
|
use Composer\Repository\InstalledArrayRepository;
|
|
|
|
use Composer\Repository\InstalledRepositoryInterface;
|
2018-11-12 14:23:32 +00:00
|
|
|
use Composer\Test\TestCase;
|
2019-01-17 16:12:33 +00:00
|
|
|
use Composer\Util\Loop;
|
2020-06-04 13:30:20 +00:00
|
|
|
use Composer\Util\ProcessExecutor;
|
2012-05-13 19:40:42 +00:00
|
|
|
|
|
|
|
class FactoryMock extends Factory
|
|
|
|
{
|
2022-08-17 12:20:07 +00:00
|
|
|
public static function createConfig(?IOInterface $io = null, ?string $cwd = null): Config
|
2012-05-13 19:40:42 +00:00
|
|
|
{
|
2014-12-16 11:12:13 +00:00
|
|
|
$config = new Config(true, $cwd);
|
2012-05-13 19:40:42 +00:00
|
|
|
|
2022-08-17 12:20:07 +00:00
|
|
|
$config->merge([
|
|
|
|
'config' => ['home' => TestCase::getUniqueTmpDirectory()],
|
|
|
|
'repositories' => ['packagist' => false],
|
|
|
|
]);
|
2012-05-13 19:40:42 +00:00
|
|
|
|
|
|
|
return $config;
|
|
|
|
}
|
|
|
|
|
2022-02-18 10:22:01 +00:00
|
|
|
protected function loadRootPackage(RepositoryManager $rm, Config $config, VersionParser $parser, VersionGuesser $guesser, IOInterface $io): RootPackageLoader
|
2020-06-19 15:56:13 +00:00
|
|
|
{
|
|
|
|
return new \Composer\Package\Loader\RootPackageLoader($rm, $config, $parser, new VersionGuesserMock(), $io);
|
|
|
|
}
|
|
|
|
|
2022-08-17 12:20:07 +00:00
|
|
|
protected function addLocalRepository(IOInterface $io, RepositoryManager $rm, string $vendorDir, RootPackageInterface $rootPackage, ?ProcessExecutor $process = null): void
|
2012-05-13 19:40:42 +00:00
|
|
|
{
|
2021-08-21 15:41:52 +00:00
|
|
|
$rm->setLocalRepository(new InstalledArrayRepository);
|
2012-05-13 19:40:42 +00:00
|
|
|
}
|
|
|
|
|
2022-08-17 12:20:07 +00:00
|
|
|
public function createInstallationManager(?Loop $loop = null, ?IOInterface $io = null, ?EventDispatcher $dispatcher = null): InstallationManager
|
2012-05-13 19:40:42 +00:00
|
|
|
{
|
2019-01-17 16:12:33 +00:00
|
|
|
return new InstallationManagerMock();
|
2012-05-13 19:40:42 +00:00
|
|
|
}
|
|
|
|
|
2022-08-17 12:20:07 +00:00
|
|
|
protected function createDefaultInstallers(InstallationManager $im, PartialComposer $composer, IOInterface $io, ?ProcessExecutor $process = null): void
|
2012-06-24 18:11:06 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-18 10:22:01 +00:00
|
|
|
protected function purgePackages(InstalledRepositoryInterface $repo, InstallationManager $im): void
|
2012-05-13 19:40:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|