mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Merge remote-tracking branch 'slbmeh/feature/gh-2787'
This commit is contained in:
commit
06be9b88c2
7 changed files with 468 additions and 5 deletions
|
@ -112,6 +112,27 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
|
|||
return $data;
|
||||
}
|
||||
|
||||
public function testPreferredInstallAsString()
|
||||
{
|
||||
$config = new Config(false);
|
||||
$config->merge(array('config' => array('preferred-install' => 'source')));
|
||||
$config->merge(array('config' => array('preferred-install' => 'dist')));
|
||||
|
||||
$this->assertEquals('dist', $config->get('preferred-install'));
|
||||
}
|
||||
|
||||
public function testMergePreferredInstall()
|
||||
{
|
||||
$config = new Config(false);
|
||||
$config->merge(array('config' => array('preferred-install' => 'dist')));
|
||||
$config->merge(array('config' => array('preferred-install' => array('foo/*' => 'source'))));
|
||||
|
||||
// This assertion needs to make sure full wildcard preferences are placed last
|
||||
// Handled by composer because we convert string preferences for BC, all other
|
||||
// care for ordering and collision prevention is up to the user
|
||||
$this->assertEquals(array('foo/*' => 'source', '*' => 'dist'), $config->get('preferred-install'));
|
||||
}
|
||||
|
||||
public function testMergeGithubOauth()
|
||||
{
|
||||
$config = new Config(false);
|
||||
|
|
|
@ -757,6 +757,366 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
|||
$manager->remove($package, 'vendor/bundles/FOS/UserBundle');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Composer\Downloader\DownloadManager::resolvePackageInstallPreference
|
||||
*/
|
||||
public function testInstallPreferenceWithoutPreferenceDev()
|
||||
{
|
||||
$package = $this->createPackageMock();
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getSourceType')
|
||||
->will($this->returnValue('git'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getDistType')
|
||||
->will($this->returnValue('pear'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('isDev')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('setInstallationSource')
|
||||
->with('source');
|
||||
|
||||
$downloader = $this->createDownloaderMock();
|
||||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||
->getMock();
|
||||
$manager
|
||||
->expects($this->once())
|
||||
->method('getDownloaderForInstalledPackage')
|
||||
->with($package)
|
||||
->will($this->returnValue($downloader));
|
||||
|
||||
$manager->download($package, 'target_dir');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Composer\Downloader\DownloadManager::resolvePackageInstallPreference
|
||||
*/
|
||||
public function testInstallPreferenceWithoutPreferenceNoDev()
|
||||
{
|
||||
$package = $this->createPackageMock();
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getSourceType')
|
||||
->will($this->returnValue('git'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getDistType')
|
||||
->will($this->returnValue('pear'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('isDev')
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('setInstallationSource')
|
||||
->with('dist');
|
||||
|
||||
$downloader = $this->createDownloaderMock();
|
||||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||
->getMock();
|
||||
$manager
|
||||
->expects($this->once())
|
||||
->method('getDownloaderForInstalledPackage')
|
||||
->with($package)
|
||||
->will($this->returnValue($downloader));
|
||||
|
||||
$manager->download($package, 'target_dir');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Composer\Downloader\DownloadManager::resolvePackageInstallPreference
|
||||
*/
|
||||
public function testInstallPreferenceWithoutMatchDev()
|
||||
{
|
||||
$package = $this->createPackageMock();
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getSourceType')
|
||||
->will($this->returnValue('git'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getDistType')
|
||||
->will($this->returnValue('pear'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('isDev')
|
||||
->will($this->returnValue(true));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getName')
|
||||
->will($this->returnValue('bar/package'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('setInstallationSource')
|
||||
->with('source');
|
||||
|
||||
$downloader = $this->createDownloaderMock();
|
||||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||
->getMock();
|
||||
$manager
|
||||
->expects($this->once())
|
||||
->method('getDownloaderForInstalledPackage')
|
||||
->with($package)
|
||||
->will($this->returnValue($downloader));
|
||||
$manager->setPreferences(array('foo/*' => 'source'));
|
||||
|
||||
$manager->download($package, 'target_dir');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Composer\Downloader\DownloadManager::resolvePackageInstallPreference
|
||||
*/
|
||||
public function testInstallPreferenceWithoutMatchNoDev()
|
||||
{
|
||||
$package = $this->createPackageMock();
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getSourceType')
|
||||
->will($this->returnValue('git'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getDistType')
|
||||
->will($this->returnValue('pear'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('isDev')
|
||||
->will($this->returnValue(false));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getName')
|
||||
->will($this->returnValue('bar/package'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('setInstallationSource')
|
||||
->with('dist');
|
||||
|
||||
$downloader = $this->createDownloaderMock();
|
||||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||
->getMock();
|
||||
$manager
|
||||
->expects($this->once())
|
||||
->method('getDownloaderForInstalledPackage')
|
||||
->with($package)
|
||||
->will($this->returnValue($downloader));
|
||||
$manager->setPreferences(array('foo/*' => 'source'));
|
||||
|
||||
$manager->download($package, 'target_dir');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Composer\Downloader\DownloadManager::resolvePackageInstallPreference
|
||||
*/
|
||||
public function testInstallPreferenceWithMatchAutoDev()
|
||||
{
|
||||
$package = $this->createPackageMock();
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getSourceType')
|
||||
->will($this->returnValue('git'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getDistType')
|
||||
->will($this->returnValue('pear'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('isDev')
|
||||
->will($this->returnValue(true));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getName')
|
||||
->will($this->returnValue('foo/package'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('setInstallationSource')
|
||||
->with('source');
|
||||
|
||||
$downloader = $this->createDownloaderMock();
|
||||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||
->getMock();
|
||||
$manager
|
||||
->expects($this->once())
|
||||
->method('getDownloaderForInstalledPackage')
|
||||
->with($package)
|
||||
->will($this->returnValue($downloader));
|
||||
$manager->setPreferences(array('foo/*' => 'auto'));
|
||||
|
||||
$manager->download($package, 'target_dir');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Composer\Downloader\DownloadManager::resolvePackageInstallPreference
|
||||
*/
|
||||
public function testInstallPreferenceWithMatchAutoNoDev()
|
||||
{
|
||||
$package = $this->createPackageMock();
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getSourceType')
|
||||
->will($this->returnValue('git'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getDistType')
|
||||
->will($this->returnValue('pear'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('isDev')
|
||||
->will($this->returnValue(false));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getName')
|
||||
->will($this->returnValue('foo/package'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('setInstallationSource')
|
||||
->with('dist');
|
||||
|
||||
$downloader = $this->createDownloaderMock();
|
||||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||
->getMock();
|
||||
$manager
|
||||
->expects($this->once())
|
||||
->method('getDownloaderForInstalledPackage')
|
||||
->with($package)
|
||||
->will($this->returnValue($downloader));
|
||||
$manager->setPreferences(array('foo/*' => 'auto'));
|
||||
|
||||
$manager->download($package, 'target_dir');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Composer\Downloader\DownloadManager::resolvePackageInstallPreference
|
||||
*/
|
||||
public function testInstallPreferenceWithMatchSource()
|
||||
{
|
||||
$package = $this->createPackageMock();
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getSourceType')
|
||||
->will($this->returnValue('git'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getDistType')
|
||||
->will($this->returnValue('pear'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getName')
|
||||
->will($this->returnValue('foo/package'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('setInstallationSource')
|
||||
->with('source');
|
||||
|
||||
$downloader = $this->createDownloaderMock();
|
||||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||
->getMock();
|
||||
$manager
|
||||
->expects($this->once())
|
||||
->method('getDownloaderForInstalledPackage')
|
||||
->with($package)
|
||||
->will($this->returnValue($downloader));
|
||||
$manager->setPreferences(array('foo/*' => 'source'));
|
||||
|
||||
$manager->download($package, 'target_dir');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Composer\Downloader\DownloadManager::resolvePackageInstallPreference
|
||||
*/
|
||||
public function testInstallPreferenceWithMatchDist()
|
||||
{
|
||||
$package = $this->createPackageMock();
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getSourceType')
|
||||
->will($this->returnValue('git'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getDistType')
|
||||
->will($this->returnValue('pear'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('getName')
|
||||
->will($this->returnValue('foo/package'));
|
||||
$package
|
||||
->expects($this->once())
|
||||
->method('setInstallationSource')
|
||||
->with('dist');
|
||||
|
||||
$downloader = $this->createDownloaderMock();
|
||||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||
->getMock();
|
||||
$manager
|
||||
->expects($this->once())
|
||||
->method('getDownloaderForInstalledPackage')
|
||||
->with($package)
|
||||
->will($this->returnValue($downloader));
|
||||
$manager->setPreferences(array('foo/*' => 'dist'));
|
||||
|
||||
$manager->download($package, 'target_dir');
|
||||
}
|
||||
|
||||
private function createDownloaderMock()
|
||||
{
|
||||
return $this->getMockBuilder('Composer\Downloader\DownloaderInterface')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue