2012-04-27 09:42:58 +00:00
|
|
|
<?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\DependencyResolver\Operation\OperationInterface;
|
|
|
|
use Composer\DependencyResolver\Operation\InstallOperation;
|
|
|
|
use Composer\DependencyResolver\Operation\UpdateOperation;
|
|
|
|
use Composer\DependencyResolver\Operation\UninstallOperation;
|
|
|
|
|
|
|
|
class InstallationManagerMock extends InstallationManager
|
|
|
|
{
|
|
|
|
private $installed = array();
|
|
|
|
private $updated = array();
|
|
|
|
private $uninstalled = array();
|
2012-05-13 19:40:42 +00:00
|
|
|
private $trace = array();
|
2012-04-27 09:42:58 +00:00
|
|
|
|
|
|
|
public function install(RepositoryInterface $repo, InstallOperation $operation)
|
|
|
|
{
|
2012-04-29 15:27:37 +00:00
|
|
|
$this->installed[] = $operation->getPackage();
|
2012-05-13 19:40:42 +00:00
|
|
|
$this->trace[] = (string) $operation;
|
|
|
|
$repo->addPackage(clone $operation->getPackage());
|
2012-04-27 09:42:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function update(RepositoryInterface $repo, UpdateOperation $operation)
|
|
|
|
{
|
2012-04-29 15:27:37 +00:00
|
|
|
$this->updated[] = array($operation->getInitialPackage(), $operation->getTargetPackage());
|
2012-05-13 19:40:42 +00:00
|
|
|
$this->trace[] = (string) $operation;
|
|
|
|
$repo->removePackage($operation->getInitialPackage());
|
|
|
|
$repo->addPackage(clone $operation->getTargetPackage());
|
2012-04-27 09:42:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function uninstall(RepositoryInterface $repo, UninstallOperation $operation)
|
|
|
|
{
|
2012-04-29 15:27:37 +00:00
|
|
|
$this->uninstalled[] = $operation->getPackage();
|
2012-05-13 19:40:42 +00:00
|
|
|
$this->trace[] = (string) $operation;
|
|
|
|
$repo->removePackage($operation->getPackage());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTrace()
|
|
|
|
{
|
|
|
|
return $this->trace;
|
2012-04-27 09:42:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getInstalledPackages()
|
|
|
|
{
|
|
|
|
return $this->installed;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUpdatedPackages()
|
|
|
|
{
|
|
|
|
return $this->updated;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUninstalledPackages()
|
|
|
|
{
|
|
|
|
return $this->uninstalled;
|
|
|
|
}
|
|
|
|
}
|