Merge remote-tracking branch 'h4cc/master'
commit
9d2d828b70
|
@ -179,7 +179,9 @@ class DownloadManager
|
||||||
$this->filesystem->ensureDirectoryExists($targetDir);
|
$this->filesystem->ensureDirectoryExists($targetDir);
|
||||||
|
|
||||||
$downloader = $this->getDownloaderForInstalledPackage($package);
|
$downloader = $this->getDownloaderForInstalledPackage($package);
|
||||||
$downloader->download($package, $targetDir);
|
if($downloader) {
|
||||||
|
$downloader->download($package, $targetDir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -194,6 +196,11 @@ class DownloadManager
|
||||||
public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
|
public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
|
||||||
{
|
{
|
||||||
$downloader = $this->getDownloaderForInstalledPackage($initial);
|
$downloader = $this->getDownloaderForInstalledPackage($initial);
|
||||||
|
if(!$downloader) {
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$installationSource = $initial->getInstallationSource();
|
$installationSource = $initial->getInstallationSource();
|
||||||
|
|
||||||
if ('dist' === $installationSource) {
|
if ('dist' === $installationSource) {
|
||||||
|
@ -230,6 +237,8 @@ class DownloadManager
|
||||||
public function remove(PackageInterface $package, $targetDir)
|
public function remove(PackageInterface $package, $targetDir)
|
||||||
{
|
{
|
||||||
$downloader = $this->getDownloaderForInstalledPackage($package);
|
$downloader = $this->getDownloaderForInstalledPackage($package);
|
||||||
$downloader->remove($package, $targetDir);
|
if($downloader) {
|
||||||
|
$downloader->remove($package, $targetDir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,6 +182,19 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
$manager->getDownloaderForInstalledPackage($package);
|
$manager->getDownloaderForInstalledPackage($package);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetDownloaderForMetapackage()
|
||||||
|
{
|
||||||
|
$package = $this->createPackageMock();
|
||||||
|
$package
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getType')
|
||||||
|
->will($this->returnValue('metapackage'));
|
||||||
|
|
||||||
|
$manager = new DownloadManager(false, $this->filesystem);
|
||||||
|
|
||||||
|
$this->assertNull($manager->getDownloaderForInstalledPackage($package));
|
||||||
|
}
|
||||||
|
|
||||||
public function testFullPackageDownload()
|
public function testFullPackageDownload()
|
||||||
{
|
{
|
||||||
$package = $this->createPackageMock();
|
$package = $this->createPackageMock();
|
||||||
|
@ -308,6 +321,36 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
$manager->download($package, 'target_dir');
|
$manager->download($package, 'target_dir');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testMetapackagePackageDownload()
|
||||||
|
{
|
||||||
|
$package = $this->createPackageMock();
|
||||||
|
$package
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getSourceType')
|
||||||
|
->will($this->returnValue('git'));
|
||||||
|
$package
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getDistType')
|
||||||
|
->will($this->returnValue(null));
|
||||||
|
|
||||||
|
$package
|
||||||
|
->expects($this->once())
|
||||||
|
->method('setInstallationSource')
|
||||||
|
->with('source');
|
||||||
|
|
||||||
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
|
->setConstructorArgs(array(false, $this->filesystem))
|
||||||
|
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||||
|
->getMock();
|
||||||
|
$manager
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getDownloaderForInstalledPackage')
|
||||||
|
->with($package)
|
||||||
|
->will($this->returnValue(null)); // There is no downloader for Metapackages.
|
||||||
|
|
||||||
|
$manager->download($package, 'target_dir');
|
||||||
|
}
|
||||||
|
|
||||||
public function testFullPackageDownloadWithSourcePreferred()
|
public function testFullPackageDownloadWithSourcePreferred()
|
||||||
{
|
{
|
||||||
$package = $this->createPackageMock();
|
$package = $this->createPackageMock();
|
||||||
|
@ -598,6 +641,24 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
$manager->update($initial, $target, 'vendor/pkg');
|
$manager->update($initial, $target, 'vendor/pkg');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testUpdateMetapackage()
|
||||||
|
{
|
||||||
|
$initial = $this->createPackageMock();
|
||||||
|
$target = $this->createPackageMock();
|
||||||
|
|
||||||
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
|
->setConstructorArgs(array(false, $this->filesystem))
|
||||||
|
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||||
|
->getMock();
|
||||||
|
$manager
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getDownloaderForInstalledPackage')
|
||||||
|
->with($initial)
|
||||||
|
->will($this->returnValue(null)); // There is no downloader for metapackages.
|
||||||
|
|
||||||
|
$manager->update($initial, $target, 'vendor/pkg');
|
||||||
|
}
|
||||||
|
|
||||||
public function testRemove()
|
public function testRemove()
|
||||||
{
|
{
|
||||||
$package = $this->createPackageMock();
|
$package = $this->createPackageMock();
|
||||||
|
@ -621,6 +682,23 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
$manager->remove($package, 'vendor/bundles/FOS/UserBundle');
|
$manager->remove($package, 'vendor/bundles/FOS/UserBundle');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testMetapackageRemove()
|
||||||
|
{
|
||||||
|
$package = $this->createPackageMock();
|
||||||
|
|
||||||
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
|
->setConstructorArgs(array(false, $this->filesystem))
|
||||||
|
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||||
|
->getMock();
|
||||||
|
$manager
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getDownloaderForInstalledPackage')
|
||||||
|
->with($package)
|
||||||
|
->will($this->returnValue(null)); // There is no downloader for metapackages.
|
||||||
|
|
||||||
|
$manager->remove($package, 'vendor/bundles/FOS/UserBundle');
|
||||||
|
}
|
||||||
|
|
||||||
private function createDownloaderMock()
|
private function createDownloaderMock()
|
||||||
{
|
{
|
||||||
return $this->getMockBuilder('Composer\Downloader\DownloaderInterface')
|
return $this->getMockBuilder('Composer\Downloader\DownloaderInterface')
|
||||||
|
|
Loading…
Reference in New Issue