1
0
Fork 0

Refactor InstallationManagerMock

pull/635/merge
Jordi Boggiano 2012-04-29 17:27:37 +02:00
parent 2dffa612a3
commit bd50ad32f0
2 changed files with 6 additions and 15 deletions

View File

@ -33,7 +33,7 @@ class InstallationManager
{ {
private $installers = array(); private $installers = array();
private $cache = array(); private $cache = array();
protected $vendorPath; private $vendorPath;
/** /**
* Creates an instance of InstallationManager * Creates an instance of InstallationManager
@ -197,14 +197,14 @@ class InstallationManager
return getcwd().DIRECTORY_SEPARATOR.$this->vendorPath; return getcwd().DIRECTORY_SEPARATOR.$this->vendorPath;
} }
protected function notifyInstall(PackageInterface $package) private function notifyInstall(PackageInterface $package)
{ {
if ($package->getRepository() instanceof NotifiableRepositoryInterface) { if ($package->getRepository() instanceof NotifiableRepositoryInterface) {
$package->getRepository()->notifyInstall($package); $package->getRepository()->notifyInstall($package);
} }
} }
protected function antiAlias(PackageInterface $package) private function antiAlias(PackageInterface $package)
{ {
if ($package instanceof AliasPackage) { if ($package instanceof AliasPackage) {
$alias = $package; $alias = $package;

View File

@ -24,28 +24,19 @@ class InstallationManagerMock extends InstallationManager
private $updated = array(); private $updated = array();
private $uninstalled = array(); private $uninstalled = array();
public function __construct($vendorDir = 'vendor')
{
$this->vendorPath = $vendorDir;
}
public function install(RepositoryInterface $repo, InstallOperation $operation) public function install(RepositoryInterface $repo, InstallOperation $operation)
{ {
$package = $this->antiAlias($operation->getPackage()); $this->installed[] = $operation->getPackage();
$this->installed[] = $package;
} }
public function update(RepositoryInterface $repo, UpdateOperation $operation) public function update(RepositoryInterface $repo, UpdateOperation $operation)
{ {
$initial = $this->antiAlias($operation->getInitialPackage()); $this->updated[] = array($operation->getInitialPackage(), $operation->getTargetPackage());
$target = $this->antiAlias($operation->getTargetPackage());
$this->updated[] = $target;
} }
public function uninstall(RepositoryInterface $repo, UninstallOperation $operation) public function uninstall(RepositoryInterface $repo, UninstallOperation $operation)
{ {
$package = $this->antiAlias($operation->getPackage()); $this->uninstalled[] = $operation->getPackage();
$this->uninstalled[] = $package;
} }
public function getInstalledPackages() public function getInstalledPackages()