Merge pull request #2259 from hason/pm
Removed duplication of logic of an installation manager in a plugin managerpull/2263/merge
commit
6f7b82e935
|
@ -232,28 +232,13 @@ class PluginManager
|
||||||
*/
|
*/
|
||||||
public function getInstallPath(PackageInterface $package, $global = false)
|
public function getInstallPath(PackageInterface $package, $global = false)
|
||||||
{
|
{
|
||||||
$targetDir = $package->getTargetDir();
|
if (!$global) {
|
||||||
|
return $this->composer->getInstallationManager()->getInstallPath($package);
|
||||||
return $this->getPackageBasePath($package, $global) . ($targetDir ? '/'.$targetDir : '');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the base path a package gets installed into.
|
|
||||||
*
|
|
||||||
* Does not take targetDir into account.
|
|
||||||
*
|
|
||||||
* @param PackageInterface $package
|
|
||||||
* @param bool $global Whether this is a global package
|
|
||||||
*
|
|
||||||
* @return string Base path
|
|
||||||
*/
|
|
||||||
protected function getPackageBasePath(PackageInterface $package, $global = false)
|
|
||||||
{
|
|
||||||
if ($global) {
|
|
||||||
$vendorDir = $this->composer->getConfig()->get('home').'/vendor';
|
|
||||||
} else {
|
|
||||||
$vendorDir = rtrim($this->composer->getConfig()->get('vendor-dir'), '/');
|
|
||||||
}
|
}
|
||||||
return ($vendorDir ? $vendorDir.'/' : '') . $package->getPrettyName();
|
|
||||||
|
$targetDir = $package->getTargetDir();
|
||||||
|
$vendorDir = $this->composer->getConfig()->get('home').'/vendor';
|
||||||
|
|
||||||
|
return ($vendorDir ? $vendorDir.'/' : '').$package->getPrettyName().($targetDir ? '/'.$targetDir : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,13 @@ class PluginInstallerTest extends \PHPUnit_Framework_TestCase
|
||||||
->method('getLocalRepository')
|
->method('getLocalRepository')
|
||||||
->will($this->returnValue($this->repository));
|
->will($this->returnValue($this->repository));
|
||||||
|
|
||||||
|
$im = $this->getMock('Composer\Installer\InstallationManager');
|
||||||
|
$im->expects($this->any())
|
||||||
|
->method('getInstallPath')
|
||||||
|
->will($this->returnCallback(function ($package) {
|
||||||
|
return __DIR__.'/Fixtures/'.$package->getPrettyName();
|
||||||
|
}));
|
||||||
|
|
||||||
$this->io = $this->getMock('Composer\IO\IOInterface');
|
$this->io = $this->getMock('Composer\IO\IOInterface');
|
||||||
|
|
||||||
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock();
|
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock();
|
||||||
|
@ -62,6 +69,7 @@ class PluginInstallerTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->composer->setConfig($config);
|
$this->composer->setConfig($config);
|
||||||
$this->composer->setDownloadManager($dm);
|
$this->composer->setDownloadManager($dm);
|
||||||
$this->composer->setRepositoryManager($rm);
|
$this->composer->setRepositoryManager($rm);
|
||||||
|
$this->composer->setInstallationManager($im);
|
||||||
$this->composer->setAutoloadGenerator($this->autoloadGenerator);
|
$this->composer->setAutoloadGenerator($this->autoloadGenerator);
|
||||||
|
|
||||||
$this->pm = new PluginManager($this->composer, $this->io);
|
$this->pm = new PluginManager($this->composer, $this->io);
|
||||||
|
|
Loading…
Reference in New Issue