123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- /*
- * 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;
- use Composer\Installer\InstallationManager;
- use Composer\Repository\RepositoryInterface;
- use Composer\Repository\InstalledRepositoryInterface;
- use Composer\Package\PackageInterface;
- use Composer\DependencyResolver\Operation\InstallOperation;
- use Composer\DependencyResolver\Operation\OperationInterface;
- use Composer\DependencyResolver\Operation\UpdateOperation;
- use Composer\DependencyResolver\Operation\UninstallOperation;
- use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
- use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
- class InstallationManagerMock extends InstallationManager
- {
- private $installed = array();
- private $updated = array();
- private $uninstalled = array();
- private $trace = array();
- public function __construct()
- {
- }
- public function execute(RepositoryInterface $repo, array $operations, $devMode = true, $runScripts = true)
- {
- foreach ($operations as $operation) {
- $method = $operation->getOperationType();
- // skipping download() step here for tests
- $this->$method($repo, $operation);
- }
- }
- public function getInstallPath(PackageInterface $package)
- {
- return '';
- }
- public function isPackageInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
- {
- return $repo->hasPackage($package);
- }
- public function install(RepositoryInterface $repo, InstallOperation $operation)
- {
- $this->installed[] = $operation->getPackage();
- $this->trace[] = strip_tags((string) $operation);
- $repo->addPackage(clone $operation->getPackage());
- }
- public function update(RepositoryInterface $repo, UpdateOperation $operation)
- {
- $this->updated[] = array($operation->getInitialPackage(), $operation->getTargetPackage());
- $this->trace[] = strip_tags((string) $operation);
- $repo->removePackage($operation->getInitialPackage());
- if (!$repo->hasPackage($operation->getTargetPackage())) {
- $repo->addPackage(clone $operation->getTargetPackage());
- }
- }
- public function uninstall(RepositoryInterface $repo, UninstallOperation $operation)
- {
- $this->uninstalled[] = $operation->getPackage();
- $this->trace[] = strip_tags((string) $operation);
- $repo->removePackage($operation->getPackage());
- }
- public function markAliasInstalled(RepositoryInterface $repo, MarkAliasInstalledOperation $operation)
- {
- $package = $operation->getPackage();
- $this->installed[] = $package;
- $this->trace[] = strip_tags((string) $operation);
- parent::markAliasInstalled($repo, $operation);
- }
- public function markAliasUninstalled(RepositoryInterface $repo, MarkAliasUninstalledOperation $operation)
- {
- $this->uninstalled[] = $operation->getPackage();
- $this->trace[] = strip_tags((string) $operation);
- parent::markAliasUninstalled($repo, $operation);
- }
- public function getTrace()
- {
- return $this->trace;
- }
- public function getInstalledPackages()
- {
- return $this->installed;
- }
- public function getUpdatedPackages()
- {
- return $this->updated;
- }
- public function getUninstalledPackages()
- {
- return $this->uninstalled;
- }
- }
|