1
0
Fork 0
composer/tests/Composer/Test/Mock/InstallationManagerMock.php

101 lines
3.0 KiB
PHP
Raw Normal View History

<?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;
2013-03-03 16:18:50 +00:00
use Composer\Repository\InstalledRepositoryInterface;
2012-06-20 10:05:18 +00:00
use Composer\Package\PackageInterface;
use Composer\DependencyResolver\Operation\InstallOperation;
use Composer\DependencyResolver\Operation\UpdateOperation;
use Composer\DependencyResolver\Operation\UninstallOperation;
2012-05-13 20:36:48 +00:00
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();
2012-06-20 10:05:18 +00:00
public function getInstallPath(PackageInterface $package)
{
return '';
}
public function isPackageInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
{
return $repo->hasPackage($package);
}
public function install(RepositoryInterface $repo, InstallOperation $operation)
{
2012-04-29 15:27:37 +00:00
$this->installed[] = $operation->getPackage();
$this->trace[] = (string) $operation;
$repo->addPackage(clone $operation->getPackage());
}
public function update(RepositoryInterface $repo, UpdateOperation $operation)
{
2012-04-29 15:27:37 +00:00
$this->updated[] = array($operation->getInitialPackage(), $operation->getTargetPackage());
$this->trace[] = (string) $operation;
$repo->removePackage($operation->getInitialPackage());
$repo->addPackage(clone $operation->getTargetPackage());
}
public function uninstall(RepositoryInterface $repo, UninstallOperation $operation)
{
2012-04-29 15:27:37 +00:00
$this->uninstalled[] = $operation->getPackage();
$this->trace[] = (string) $operation;
$repo->removePackage($operation->getPackage());
}
2012-05-13 20:36:48 +00:00
public function markAliasInstalled(RepositoryInterface $repo, MarkAliasInstalledOperation $operation)
{
$package = $operation->getPackage();
$this->installed[] = $package;
2012-05-13 20:36:48 +00:00
$this->trace[] = (string) $operation;
parent::markAliasInstalled($repo, $operation);
2012-05-13 20:36:48 +00:00
}
public function markAliasUninstalled(RepositoryInterface $repo, MarkAliasUninstalledOperation $operation)
{
$this->uninstalled[] = $operation->getPackage();
$this->trace[] = (string) $operation;
parent::markAliasUninstalled($repo, $operation);
2012-05-13 20:36:48 +00:00
}
public function getTrace()
{
return $this->trace;
}
public function getInstalledPackages()
{
return $this->installed;
}
public function getUpdatedPackages()
{
return $this->updated;
}
public function getUninstalledPackages()
{
return $this->uninstalled;
}
}