Merge branch 'master' of github.com:composer/composer into tls-config
commit
30c6aa3183
|
@ -292,6 +292,11 @@ The VCS driver to be used is detected automatically based on the URL. However,
|
||||||
should you need to specify one for whatever reason, you can use `git`, `svn` or
|
should you need to specify one for whatever reason, you can use `git`, `svn` or
|
||||||
`hg` as the repository type instead of `vcs`.
|
`hg` as the repository type instead of `vcs`.
|
||||||
|
|
||||||
|
If you set the `no-api` key to `true` on a github repository it will clone the
|
||||||
|
repository as it would with any other git repository instead of using the
|
||||||
|
GitHub API. But unlike using the `git` driver directly, composer will still
|
||||||
|
attempt to use github's zip files.
|
||||||
|
|
||||||
#### Subversion Options
|
#### Subversion Options
|
||||||
|
|
||||||
Since Subversion has no native concept of branches and tags, Composer assumes
|
Since Subversion has no native concept of branches and tags, Composer assumes
|
||||||
|
|
|
@ -102,22 +102,7 @@ EOT
|
||||||
|
|
||||||
$preferSource = false;
|
$preferSource = false;
|
||||||
$preferDist = false;
|
$preferDist = false;
|
||||||
switch ($config->get('preferred-install')) {
|
$this->updatePreferredOptions($config, $input, $preferSource, $preferDist);
|
||||||
case 'source':
|
|
||||||
$preferSource = true;
|
|
||||||
break;
|
|
||||||
case 'dist':
|
|
||||||
$preferDist = true;
|
|
||||||
break;
|
|
||||||
case 'auto':
|
|
||||||
default:
|
|
||||||
// noop
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ($input->getOption('prefer-source') || $input->getOption('prefer-dist')) {
|
|
||||||
$preferSource = $input->getOption('prefer-source');
|
|
||||||
$preferDist = $input->getOption('prefer-dist');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($input->getOption('no-custom-installers')) {
|
if ($input->getOption('no-custom-installers')) {
|
||||||
$output->writeln('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
|
$output->writeln('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
|
||||||
|
@ -139,11 +124,12 @@ EOT
|
||||||
$input->getOption('no-scripts'),
|
$input->getOption('no-scripts'),
|
||||||
$input->getOption('keep-vcs'),
|
$input->getOption('keep-vcs'),
|
||||||
$input->getOption('no-progress'),
|
$input->getOption('no-progress'),
|
||||||
$input->getOption('no-install')
|
$input->getOption('no-install'),
|
||||||
|
$input
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function installProject(IOInterface $io, $config, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositoryUrl = null, $disablePlugins = false, $noScripts = false, $keepVcs = false, $noProgress = false, $noInstall = false)
|
public function installProject(IOInterface $io, Config $config, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositoryUrl = null, $disablePlugins = false, $noScripts = false, $keepVcs = false, $noProgress = false, $noInstall = false, InputInterface $input)
|
||||||
{
|
{
|
||||||
$oldCwd = getcwd();
|
$oldCwd = getcwd();
|
||||||
|
|
||||||
|
@ -161,6 +147,9 @@ EOT
|
||||||
$composer->getEventDispatcher()->dispatchCommandEvent(ScriptEvents::POST_ROOT_PACKAGE_INSTALL, $installDevPackages);
|
$composer->getEventDispatcher()->dispatchCommandEvent(ScriptEvents::POST_ROOT_PACKAGE_INSTALL, $installDevPackages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$rootPackageConfig = $composer->getConfig();
|
||||||
|
$this->updatePreferredOptions($rootPackageConfig, $input, $preferSource, $preferDist);
|
||||||
|
|
||||||
// install dependencies of the created project
|
// install dependencies of the created project
|
||||||
if ($noInstall === false) {
|
if ($noInstall === false) {
|
||||||
$installer = Installer::create($io, $composer);
|
$installer = Installer::create($io, $composer);
|
||||||
|
@ -238,7 +227,7 @@ EOT
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function installRootPackage(IOInterface $io, $config, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositoryUrl = null, $disablePlugins = false, $noScripts = false, $keepVcs = false, $noProgress = false)
|
protected function installRootPackage(IOInterface $io, Config $config, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositoryUrl = null, $disablePlugins = false, $noScripts = false, $keepVcs = false, $noProgress = false)
|
||||||
{
|
{
|
||||||
if (null === $repositoryUrl) {
|
if (null === $repositoryUrl) {
|
||||||
$sourceRepo = new CompositeRepository(Factory::createDefaultRepositories($io, $config));
|
$sourceRepo = new CompositeRepository(Factory::createDefaultRepositories($io, $config));
|
||||||
|
@ -343,4 +332,35 @@ EOT
|
||||||
{
|
{
|
||||||
return new InstallationManager();
|
return new InstallationManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updated preferSource or preferDist based on the preferredInstall config option
|
||||||
|
* @param Config $config
|
||||||
|
* @param InputInterface $input
|
||||||
|
* @param boolean $preferSource
|
||||||
|
* @param boolean $preferDist
|
||||||
|
*/
|
||||||
|
protected function updatePreferredOptions(Config $config, InputInterface $input, &$preferSource, &$preferDist)
|
||||||
|
{
|
||||||
|
switch ($config->get('preferred-install')) {
|
||||||
|
case 'source':
|
||||||
|
$preferSource = true;
|
||||||
|
$preferDist = false;
|
||||||
|
break;
|
||||||
|
case 'dist':
|
||||||
|
$preferSource = false;
|
||||||
|
$preferDist = true;
|
||||||
|
break;
|
||||||
|
case 'auto':
|
||||||
|
default:
|
||||||
|
// noop
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($input->getOption('prefer-source') || $input->getOption('prefer-dist')) {
|
||||||
|
$preferSource = $input->getOption('prefer-source');
|
||||||
|
$preferDist = $input->getOption('prefer-dist');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace Composer\Downloader;
|
||||||
|
|
||||||
use Composer\Package\PackageInterface;
|
use Composer\Package\PackageInterface;
|
||||||
use Composer\Downloader\DownloaderInterface;
|
use Composer\Downloader\DownloaderInterface;
|
||||||
|
use Composer\IO\IOInterface;
|
||||||
use Composer\Util\Filesystem;
|
use Composer\Util\Filesystem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,6 +24,7 @@ use Composer\Util\Filesystem;
|
||||||
*/
|
*/
|
||||||
class DownloadManager
|
class DownloadManager
|
||||||
{
|
{
|
||||||
|
private $io;
|
||||||
private $preferDist = false;
|
private $preferDist = false;
|
||||||
private $preferSource = false;
|
private $preferSource = false;
|
||||||
private $filesystem;
|
private $filesystem;
|
||||||
|
@ -31,11 +33,13 @@ class DownloadManager
|
||||||
/**
|
/**
|
||||||
* Initializes download manager.
|
* Initializes download manager.
|
||||||
*
|
*
|
||||||
|
* @param IOInterface $io The Input Output Interface
|
||||||
* @param bool $preferSource prefer downloading from source
|
* @param bool $preferSource prefer downloading from source
|
||||||
* @param Filesystem|null $filesystem custom Filesystem object
|
* @param Filesystem|null $filesystem custom Filesystem object
|
||||||
*/
|
*/
|
||||||
public function __construct($preferSource = false, Filesystem $filesystem = null)
|
public function __construct(IOInterface $io, $preferSource = false, Filesystem $filesystem = null)
|
||||||
{
|
{
|
||||||
|
$this->io = $io;
|
||||||
$this->preferSource = $preferSource;
|
$this->preferSource = $preferSource;
|
||||||
$this->filesystem = $filesystem ?: new Filesystem();
|
$this->filesystem = $filesystem ?: new Filesystem();
|
||||||
}
|
}
|
||||||
|
@ -168,20 +172,48 @@ class DownloadManager
|
||||||
$sourceType = $package->getSourceType();
|
$sourceType = $package->getSourceType();
|
||||||
$distType = $package->getDistType();
|
$distType = $package->getDistType();
|
||||||
|
|
||||||
if ((!$package->isDev() || $this->preferDist || !$sourceType) && !($preferSource && $sourceType) && $distType) {
|
$sources = array();
|
||||||
$package->setInstallationSource('dist');
|
if ($sourceType) {
|
||||||
} elseif ($sourceType) {
|
$sources[] = 'source';
|
||||||
$package->setInstallationSource('source');
|
}
|
||||||
} else {
|
if ($distType) {
|
||||||
|
$sources[] = 'dist';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($sources)) {
|
||||||
throw new \InvalidArgumentException('Package '.$package.' must have a source or dist specified');
|
throw new \InvalidArgumentException('Package '.$package.' must have a source or dist specified');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((!$package->isDev() || $this->preferDist) && !$preferSource) {
|
||||||
|
$sources = array_reverse($sources);
|
||||||
|
}
|
||||||
|
|
||||||
$this->filesystem->ensureDirectoryExists($targetDir);
|
$this->filesystem->ensureDirectoryExists($targetDir);
|
||||||
|
|
||||||
|
foreach ($sources as $i => $source) {
|
||||||
|
if (isset($e)) {
|
||||||
|
$this->io->write('<warning>Now trying to download from ' . $source . '</warning>');
|
||||||
|
}
|
||||||
|
$package->setInstallationSource($source);
|
||||||
|
try {
|
||||||
$downloader = $this->getDownloaderForInstalledPackage($package);
|
$downloader = $this->getDownloaderForInstalledPackage($package);
|
||||||
if ($downloader) {
|
if ($downloader) {
|
||||||
$downloader->download($package, $targetDir);
|
$downloader->download($package, $targetDir);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
} catch (\RuntimeException $e) {
|
||||||
|
if ($i == count($sources) - 1) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->io->write(
|
||||||
|
'<warning>Failed to download '.
|
||||||
|
$package->getPrettyName().
|
||||||
|
' from ' . $source . ': '.
|
||||||
|
$e->getMessage().'</warning>'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Composer\Downloader;
|
||||||
/**
|
/**
|
||||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||||
*/
|
*/
|
||||||
class TransportException extends \Exception
|
class TransportException extends \RuntimeException
|
||||||
{
|
{
|
||||||
protected $headers;
|
protected $headers;
|
||||||
|
|
||||||
|
|
|
@ -366,7 +366,7 @@ class Factory
|
||||||
$cache = new Cache($io, $config->get('cache-files-dir'), 'a-z0-9_./');
|
$cache = new Cache($io, $config->get('cache-files-dir'), 'a-z0-9_./');
|
||||||
}
|
}
|
||||||
|
|
||||||
$dm = new Downloader\DownloadManager();
|
$dm = new Downloader\DownloadManager($io);
|
||||||
switch ($config->get('preferred-install')) {
|
switch ($config->get('preferred-install')) {
|
||||||
case 'dist':
|
case 'dist':
|
||||||
$dm->setPreferDist(true);
|
$dm->setPreferDist(true);
|
||||||
|
|
|
@ -52,6 +52,11 @@ class GitHubDriver extends VcsDriver
|
||||||
$this->originUrl = !empty($match[1]) ? $match[1] : $match[2];
|
$this->originUrl = !empty($match[1]) ? $match[1] : $match[2];
|
||||||
$this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository);
|
$this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository);
|
||||||
|
|
||||||
|
if (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api']) {
|
||||||
|
$this->setupGitDriver($this->url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->fetchRootIdentifier();
|
$this->fetchRootIdentifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,10 +122,6 @@ class GitHubDriver extends VcsDriver
|
||||||
*/
|
*/
|
||||||
public function getDist($identifier)
|
public function getDist($identifier)
|
||||||
{
|
{
|
||||||
if ($this->gitDriver) {
|
|
||||||
return $this->gitDriver->getDist($identifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
$url = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/zipball/'.$identifier;
|
$url = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/zipball/'.$identifier;
|
||||||
|
|
||||||
return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
|
return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
|
||||||
|
@ -405,14 +406,7 @@ class GitHubDriver extends VcsDriver
|
||||||
// GitHub returns 404 for private repositories) and we
|
// GitHub returns 404 for private repositories) and we
|
||||||
// cannot ask for authentication credentials (because we
|
// cannot ask for authentication credentials (because we
|
||||||
// are not interactive) then we fallback to GitDriver.
|
// are not interactive) then we fallback to GitDriver.
|
||||||
$this->gitDriver = new GitDriver(
|
$this->setupGitDriver($this->generateSshUrl());
|
||||||
array('url' => $this->generateSshUrl()),
|
|
||||||
$this->io,
|
|
||||||
$this->config,
|
|
||||||
$this->process,
|
|
||||||
$this->remoteFilesystem
|
|
||||||
);
|
|
||||||
$this->gitDriver->initialize();
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} catch (\RuntimeException $e) {
|
} catch (\RuntimeException $e) {
|
||||||
|
@ -422,4 +416,16 @@ class GitHubDriver extends VcsDriver
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function setupGitDriver($url)
|
||||||
|
{
|
||||||
|
$this->gitDriver = new GitDriver(
|
||||||
|
array('url' => $url),
|
||||||
|
$this->io,
|
||||||
|
$this->config,
|
||||||
|
$this->process,
|
||||||
|
$this->remoteFilesystem
|
||||||
|
);
|
||||||
|
$this->gitDriver->initialize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,8 @@ class ComposerTest extends TestCase
|
||||||
public function testSetGetDownloadManager()
|
public function testSetGetDownloadManager()
|
||||||
{
|
{
|
||||||
$composer = new Composer();
|
$composer = new Composer();
|
||||||
$manager = $this->getMock('Composer\Downloader\DownloadManager');
|
$io = $this->getMock('Composer\IO\IOInterface');
|
||||||
|
$manager = $this->getMock('Composer\Downloader\DownloadManager', array(), array($io));
|
||||||
$composer->setDownloadManager($manager);
|
$composer->setDownloadManager($manager);
|
||||||
|
|
||||||
$this->assertSame($manager, $composer->getDownloadManager());
|
$this->assertSame($manager, $composer->getDownloadManager());
|
||||||
|
|
|
@ -17,16 +17,18 @@ use Composer\Downloader\DownloadManager;
|
||||||
class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
protected $filesystem;
|
protected $filesystem;
|
||||||
|
protected $io;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->filesystem = $this->getMock('Composer\Util\Filesystem');
|
$this->filesystem = $this->getMock('Composer\Util\Filesystem');
|
||||||
|
$this->io = $this->getMock('Composer\IO\IOInterface');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetGetDownloader()
|
public function testSetGetDownloader()
|
||||||
{
|
{
|
||||||
$downloader = $this->createDownloaderMock();
|
$downloader = $this->createDownloaderMock();
|
||||||
$manager = new DownloadManager(false, $this->filesystem);
|
$manager = new DownloadManager($this->io, false, $this->filesystem);
|
||||||
|
|
||||||
$manager->setDownloader('test', $downloader);
|
$manager->setDownloader('test', $downloader);
|
||||||
$this->assertSame($downloader, $manager->getDownloader('test'));
|
$this->assertSame($downloader, $manager->getDownloader('test'));
|
||||||
|
@ -43,7 +45,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->method('getInstallationSource')
|
->method('getInstallationSource')
|
||||||
->will($this->returnValue(null));
|
->will($this->returnValue(null));
|
||||||
|
|
||||||
$manager = new DownloadManager(false, $this->filesystem);
|
$manager = new DownloadManager($this->io, false, $this->filesystem);
|
||||||
|
|
||||||
$this->setExpectedException('InvalidArgumentException');
|
$this->setExpectedException('InvalidArgumentException');
|
||||||
|
|
||||||
|
@ -69,7 +71,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->will($this->returnValue('dist'));
|
->will($this->returnValue('dist'));
|
||||||
|
|
||||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
->setConstructorArgs(array(false, $this->filesystem))
|
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||||
->setMethods(array('getDownloader'))
|
->setMethods(array('getDownloader'))
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
|
@ -101,7 +103,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->will($this->returnValue('source'));
|
->will($this->returnValue('source'));
|
||||||
|
|
||||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
->setConstructorArgs(array(false, $this->filesystem))
|
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||||
->setMethods(array('getDownloader'))
|
->setMethods(array('getDownloader'))
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
|
@ -135,7 +137,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->will($this->returnValue('source'));
|
->will($this->returnValue('source'));
|
||||||
|
|
||||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
->setConstructorArgs(array(false, $this->filesystem))
|
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||||
->setMethods(array('getDownloader'))
|
->setMethods(array('getDownloader'))
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
|
@ -167,7 +169,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->will($this->returnValue('dist'));
|
->will($this->returnValue('dist'));
|
||||||
|
|
||||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
->setConstructorArgs(array(false, $this->filesystem))
|
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||||
->setMethods(array('getDownloader'))
|
->setMethods(array('getDownloader'))
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
|
@ -190,7 +192,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->method('getType')
|
->method('getType')
|
||||||
->will($this->returnValue('metapackage'));
|
->will($this->returnValue('metapackage'));
|
||||||
|
|
||||||
$manager = new DownloadManager(false, $this->filesystem);
|
$manager = new DownloadManager($this->io, false, $this->filesystem);
|
||||||
|
|
||||||
$this->assertNull($manager->getDownloaderForInstalledPackage($package));
|
$this->assertNull($manager->getDownloaderForInstalledPackage($package));
|
||||||
}
|
}
|
||||||
|
@ -219,7 +221,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->with($package, 'target_dir');
|
->with($package, 'target_dir');
|
||||||
|
|
||||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
->setConstructorArgs(array(false, $this->filesystem))
|
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||||
->setMethods(array('getDownloaderForInstalledPackage'))
|
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||||
->getMock();
|
->getMock();
|
||||||
$manager
|
$manager
|
||||||
|
@ -231,6 +233,62 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
$manager->download($package, 'target_dir');
|
$manager->download($package, 'target_dir');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFullPackageDownloadFailover()
|
||||||
|
{
|
||||||
|
$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->any())
|
||||||
|
->method('getPrettyString')
|
||||||
|
->will($this->returnValue('prettyPackage'));
|
||||||
|
|
||||||
|
$package
|
||||||
|
->expects($this->at(3))
|
||||||
|
->method('setInstallationSource')
|
||||||
|
->with('dist');
|
||||||
|
$package
|
||||||
|
->expects($this->at(5))
|
||||||
|
->method('setInstallationSource')
|
||||||
|
->with('source');
|
||||||
|
|
||||||
|
$downloaderFail = $this->createDownloaderMock();
|
||||||
|
$downloaderFail
|
||||||
|
->expects($this->once())
|
||||||
|
->method('download')
|
||||||
|
->with($package, 'target_dir')
|
||||||
|
->will($this->throwException(new \RuntimeException("Foo")));
|
||||||
|
|
||||||
|
$downloaderSuccess = $this->createDownloaderMock();
|
||||||
|
$downloaderSuccess
|
||||||
|
->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->at(0))
|
||||||
|
->method('getDownloaderForInstalledPackage')
|
||||||
|
->with($package)
|
||||||
|
->will($this->returnValue($downloaderFail));
|
||||||
|
$manager
|
||||||
|
->expects($this->at(1))
|
||||||
|
->method('getDownloaderForInstalledPackage')
|
||||||
|
->with($package)
|
||||||
|
->will($this->returnValue($downloaderSuccess));
|
||||||
|
|
||||||
|
$manager->download($package, 'target_dir');
|
||||||
|
}
|
||||||
|
|
||||||
public function testBadPackageDownload()
|
public function testBadPackageDownload()
|
||||||
{
|
{
|
||||||
$package = $this->createPackageMock();
|
$package = $this->createPackageMock();
|
||||||
|
@ -243,7 +301,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->method('getDistType')
|
->method('getDistType')
|
||||||
->will($this->returnValue(null));
|
->will($this->returnValue(null));
|
||||||
|
|
||||||
$manager = new DownloadManager(false, $this->filesystem);
|
$manager = new DownloadManager($this->io, false, $this->filesystem);
|
||||||
|
|
||||||
$this->setExpectedException('InvalidArgumentException');
|
$this->setExpectedException('InvalidArgumentException');
|
||||||
$manager->download($package, 'target_dir');
|
$manager->download($package, 'target_dir');
|
||||||
|
@ -273,7 +331,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->with($package, 'target_dir');
|
->with($package, 'target_dir');
|
||||||
|
|
||||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
->setConstructorArgs(array(false, $this->filesystem))
|
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||||
->setMethods(array('getDownloaderForInstalledPackage'))
|
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||||
->getMock();
|
->getMock();
|
||||||
$manager
|
$manager
|
||||||
|
@ -309,7 +367,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->with($package, 'target_dir');
|
->with($package, 'target_dir');
|
||||||
|
|
||||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
->setConstructorArgs(array(false, $this->filesystem))
|
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||||
->setMethods(array('getDownloaderForInstalledPackage'))
|
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||||
->getMock();
|
->getMock();
|
||||||
$manager
|
$manager
|
||||||
|
@ -339,7 +397,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->with('source');
|
->with('source');
|
||||||
|
|
||||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
->setConstructorArgs(array(false, $this->filesystem))
|
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||||
->setMethods(array('getDownloaderForInstalledPackage'))
|
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||||
->getMock();
|
->getMock();
|
||||||
$manager
|
$manager
|
||||||
|
@ -375,7 +433,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->with($package, 'target_dir');
|
->with($package, 'target_dir');
|
||||||
|
|
||||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
->setConstructorArgs(array(false, $this->filesystem))
|
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||||
->setMethods(array('getDownloaderForInstalledPackage'))
|
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||||
->getMock();
|
->getMock();
|
||||||
$manager
|
$manager
|
||||||
|
@ -412,7 +470,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->with($package, 'target_dir');
|
->with($package, 'target_dir');
|
||||||
|
|
||||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
->setConstructorArgs(array(false, $this->filesystem))
|
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||||
->setMethods(array('getDownloaderForInstalledPackage'))
|
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||||
->getMock();
|
->getMock();
|
||||||
$manager
|
$manager
|
||||||
|
@ -449,7 +507,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->with($package, 'target_dir');
|
->with($package, 'target_dir');
|
||||||
|
|
||||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
->setConstructorArgs(array(false, $this->filesystem))
|
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||||
->setMethods(array('getDownloaderForInstalledPackage'))
|
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||||
->getMock();
|
->getMock();
|
||||||
$manager
|
$manager
|
||||||
|
@ -474,7 +532,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->method('getDistType')
|
->method('getDistType')
|
||||||
->will($this->returnValue(null));
|
->will($this->returnValue(null));
|
||||||
|
|
||||||
$manager = new DownloadManager(false, $this->filesystem);
|
$manager = new DownloadManager($this->io, false, $this->filesystem);
|
||||||
$manager->setPreferSource(true);
|
$manager->setPreferSource(true);
|
||||||
|
|
||||||
$this->setExpectedException('InvalidArgumentException');
|
$this->setExpectedException('InvalidArgumentException');
|
||||||
|
@ -510,7 +568,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->with($initial, $target, 'vendor/bundles/FOS/UserBundle');
|
->with($initial, $target, 'vendor/bundles/FOS/UserBundle');
|
||||||
|
|
||||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
->setConstructorArgs(array(false, $this->filesystem))
|
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||||
->setMethods(array('getDownloaderForInstalledPackage'))
|
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||||
->getMock();
|
->getMock();
|
||||||
$manager
|
$manager
|
||||||
|
@ -547,7 +605,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->with($initial, 'vendor/bundles/FOS/UserBundle');
|
->with($initial, 'vendor/bundles/FOS/UserBundle');
|
||||||
|
|
||||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
->setConstructorArgs(array(false, $this->filesystem))
|
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||||
->setMethods(array('getDownloaderForInstalledPackage', 'download'))
|
->setMethods(array('getDownloaderForInstalledPackage', 'download'))
|
||||||
->getMock();
|
->getMock();
|
||||||
$manager
|
$manager
|
||||||
|
@ -588,7 +646,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->with($initial, $target, 'vendor/pkg');
|
->with($initial, $target, 'vendor/pkg');
|
||||||
|
|
||||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
->setConstructorArgs(array(false, $this->filesystem))
|
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||||
->setMethods(array('getDownloaderForInstalledPackage', 'download'))
|
->setMethods(array('getDownloaderForInstalledPackage', 'download'))
|
||||||
->getMock();
|
->getMock();
|
||||||
$manager
|
$manager
|
||||||
|
@ -625,7 +683,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->with($initial, 'vendor/pkg');
|
->with($initial, 'vendor/pkg');
|
||||||
|
|
||||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
->setConstructorArgs(array(false, $this->filesystem))
|
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||||
->setMethods(array('getDownloaderForInstalledPackage', 'download'))
|
->setMethods(array('getDownloaderForInstalledPackage', 'download'))
|
||||||
->getMock();
|
->getMock();
|
||||||
$manager
|
$manager
|
||||||
|
@ -647,7 +705,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
$target = $this->createPackageMock();
|
$target = $this->createPackageMock();
|
||||||
|
|
||||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
->setConstructorArgs(array(false, $this->filesystem))
|
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||||
->setMethods(array('getDownloaderForInstalledPackage'))
|
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||||
->getMock();
|
->getMock();
|
||||||
$manager
|
$manager
|
||||||
|
@ -670,7 +728,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
->with($package, 'vendor/bundles/FOS/UserBundle');
|
->with($package, 'vendor/bundles/FOS/UserBundle');
|
||||||
|
|
||||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
->setConstructorArgs(array(false, $this->filesystem))
|
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||||
->setMethods(array('getDownloaderForInstalledPackage'))
|
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||||
->getMock();
|
->getMock();
|
||||||
$manager
|
$manager
|
||||||
|
@ -687,7 +745,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
$package = $this->createPackageMock();
|
$package = $this->createPackageMock();
|
||||||
|
|
||||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||||
->setConstructorArgs(array(false, $this->filesystem))
|
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||||
->setMethods(array('getDownloaderForInstalledPackage'))
|
->setMethods(array('getDownloaderForInstalledPackage'))
|
||||||
->getMock();
|
->getMock();
|
||||||
$manager
|
$manager
|
||||||
|
|
|
@ -51,7 +51,7 @@ class InstallerTest extends TestCase
|
||||||
{
|
{
|
||||||
$io = $this->getMock('Composer\IO\IOInterface');
|
$io = $this->getMock('Composer\IO\IOInterface');
|
||||||
|
|
||||||
$downloadManager = $this->getMock('Composer\Downloader\DownloadManager');
|
$downloadManager = $this->getMock('Composer\Downloader\DownloadManager', array(), array($io));
|
||||||
$config = $this->getMock('Composer\Config');
|
$config = $this->getMock('Composer\Config');
|
||||||
|
|
||||||
$repositoryManager = new RepositoryManager($io, $config);
|
$repositoryManager = new RepositoryManager($io, $config);
|
||||||
|
|
|
@ -283,19 +283,16 @@ class GitHubDriverTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$this->assertEquals('test_master', $gitHubDriver->getRootIdentifier());
|
$this->assertEquals('test_master', $gitHubDriver->getRootIdentifier());
|
||||||
|
|
||||||
// Dist is not available for GitDriver
|
$dist = $gitHubDriver->getDist($sha);
|
||||||
$dist = $gitHubDriver->getDist($identifier);
|
$this->assertEquals('zip', $dist['type']);
|
||||||
$this->assertNull($dist);
|
$this->assertEquals('https://api.github.com/repos/composer/packagist/zipball/SOMESHA', $dist['url']);
|
||||||
|
$this->assertEquals($sha, $dist['reference']);
|
||||||
|
|
||||||
$source = $gitHubDriver->getSource($identifier);
|
$source = $gitHubDriver->getSource($identifier);
|
||||||
$this->assertEquals('git', $source['type']);
|
$this->assertEquals('git', $source['type']);
|
||||||
$this->assertEquals($repoSshUrl, $source['url']);
|
$this->assertEquals($repoSshUrl, $source['url']);
|
||||||
$this->assertEquals($identifier, $source['reference']);
|
$this->assertEquals($identifier, $source['reference']);
|
||||||
|
|
||||||
// Dist is not available for GitDriver
|
|
||||||
$dist = $gitHubDriver->getDist($sha);
|
|
||||||
$this->assertNull($dist);
|
|
||||||
|
|
||||||
$source = $gitHubDriver->getSource($sha);
|
$source = $gitHubDriver->getSource($sha);
|
||||||
$this->assertEquals('git', $source['type']);
|
$this->assertEquals('git', $source['type']);
|
||||||
$this->assertEquals($repoSshUrl, $source['url']);
|
$this->assertEquals($repoSshUrl, $source['url']);
|
||||||
|
|
Loading…
Reference in New Issue