mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Add parallel download capability to FileDownloader and derivatives
This commit is contained in:
parent
0f2f950cb6
commit
3dfcae99a9
50 changed files with 803 additions and 492 deletions
|
@ -13,6 +13,7 @@
|
|||
namespace Composer\Test\Installer;
|
||||
|
||||
use Composer\Installer\InstallationManager;
|
||||
use Composer\Installer\NoopInstaller;
|
||||
use Composer\DependencyResolver\Operation\InstallOperation;
|
||||
use Composer\DependencyResolver\Operation\UpdateOperation;
|
||||
use Composer\DependencyResolver\Operation\UninstallOperation;
|
||||
|
@ -21,9 +22,11 @@ use PHPUnit\Framework\TestCase;
|
|||
class InstallationManagerTest extends TestCase
|
||||
{
|
||||
protected $repository;
|
||||
protected $loop;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->loop = $this->getMockBuilder('Composer\Util\Loop')->disableOriginalConstructor()->getMock();
|
||||
$this->repository = $this->getMockBuilder('Composer\Repository\InstalledRepositoryInterface')->getMock();
|
||||
}
|
||||
|
||||
|
@ -38,7 +41,7 @@ class InstallationManagerTest extends TestCase
|
|||
return $arg === 'vendor';
|
||||
}));
|
||||
|
||||
$manager = new InstallationManager();
|
||||
$manager = new InstallationManager($this->loop);
|
||||
|
||||
$manager->addInstaller($installer);
|
||||
$this->assertSame($installer, $manager->getInstaller('vendor'));
|
||||
|
@ -67,7 +70,7 @@ class InstallationManagerTest extends TestCase
|
|||
return $arg === 'vendor';
|
||||
}));
|
||||
|
||||
$manager = new InstallationManager();
|
||||
$manager = new InstallationManager($this->loop);
|
||||
|
||||
$manager->addInstaller($installer);
|
||||
$this->assertSame($installer, $manager->getInstaller('vendor'));
|
||||
|
@ -80,16 +83,21 @@ class InstallationManagerTest extends TestCase
|
|||
public function testExecute()
|
||||
{
|
||||
$manager = $this->getMockBuilder('Composer\Installer\InstallationManager')
|
||||
->setConstructorArgs(array($this->loop))
|
||||
->setMethods(array('install', 'update', 'uninstall'))
|
||||
->getMock();
|
||||
|
||||
$installOperation = new InstallOperation($this->createPackageMock());
|
||||
$removeOperation = new UninstallOperation($this->createPackageMock());
|
||||
$installOperation = new InstallOperation($package = $this->createPackageMock());
|
||||
$removeOperation = new UninstallOperation($package);
|
||||
$updateOperation = new UpdateOperation(
|
||||
$this->createPackageMock(),
|
||||
$this->createPackageMock()
|
||||
$package,
|
||||
$package
|
||||
);
|
||||
|
||||
$package->expects($this->any())
|
||||
->method('getType')
|
||||
->will($this->returnValue('library'));
|
||||
|
||||
$manager
|
||||
->expects($this->once())
|
||||
->method('install')
|
||||
|
@ -103,6 +111,7 @@ class InstallationManagerTest extends TestCase
|
|||
->method('update')
|
||||
->with($this->repository, $updateOperation);
|
||||
|
||||
$manager->addInstaller(new NoopInstaller());
|
||||
$manager->execute($this->repository, $installOperation);
|
||||
$manager->execute($this->repository, $removeOperation);
|
||||
$manager->execute($this->repository, $updateOperation);
|
||||
|
@ -111,7 +120,7 @@ class InstallationManagerTest extends TestCase
|
|||
public function testInstall()
|
||||
{
|
||||
$installer = $this->createInstallerMock();
|
||||
$manager = new InstallationManager();
|
||||
$manager = new InstallationManager($this->loop);
|
||||
$manager->addInstaller($installer);
|
||||
|
||||
$package = $this->createPackageMock();
|
||||
|
@ -139,7 +148,7 @@ class InstallationManagerTest extends TestCase
|
|||
public function testUpdateWithEqualTypes()
|
||||
{
|
||||
$installer = $this->createInstallerMock();
|
||||
$manager = new InstallationManager();
|
||||
$manager = new InstallationManager($this->loop);
|
||||
$manager->addInstaller($installer);
|
||||
|
||||
$initial = $this->createPackageMock();
|
||||
|
@ -173,18 +182,17 @@ class InstallationManagerTest extends TestCase
|
|||
{
|
||||
$libInstaller = $this->createInstallerMock();
|
||||
$bundleInstaller = $this->createInstallerMock();
|
||||
$manager = new InstallationManager();
|
||||
$manager = new InstallationManager($this->loop);
|
||||
$manager->addInstaller($libInstaller);
|
||||
$manager->addInstaller($bundleInstaller);
|
||||
|
||||
$initial = $this->createPackageMock();
|
||||
$target = $this->createPackageMock();
|
||||
$operation = new UpdateOperation($initial, $target, 'test');
|
||||
|
||||
$initial
|
||||
->expects($this->once())
|
||||
->method('getType')
|
||||
->will($this->returnValue('library'));
|
||||
|
||||
$target = $this->createPackageMock();
|
||||
$target
|
||||
->expects($this->once())
|
||||
->method('getType')
|
||||
|
@ -213,13 +221,14 @@ class InstallationManagerTest extends TestCase
|
|||
->method('install')
|
||||
->with($this->repository, $target);
|
||||
|
||||
$operation = new UpdateOperation($initial, $target, 'test');
|
||||
$manager->update($this->repository, $operation);
|
||||
}
|
||||
|
||||
public function testUninstall()
|
||||
{
|
||||
$installer = $this->createInstallerMock();
|
||||
$manager = new InstallationManager();
|
||||
$manager = new InstallationManager($this->loop);
|
||||
$manager->addInstaller($installer);
|
||||
|
||||
$package = $this->createPackageMock();
|
||||
|
@ -249,7 +258,7 @@ class InstallationManagerTest extends TestCase
|
|||
$installer = $this->getMockBuilder('Composer\Installer\LibraryInstaller')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$manager = new InstallationManager();
|
||||
$manager = new InstallationManager($this->loop);
|
||||
$manager->addInstaller($installer);
|
||||
|
||||
$package = $this->createPackageMock();
|
||||
|
@ -281,7 +290,9 @@ class InstallationManagerTest extends TestCase
|
|||
|
||||
private function createPackageMock()
|
||||
{
|
||||
return $this->getMockBuilder('Composer\Package\PackageInterface')
|
||||
$mock = $this->getMockBuilder('Composer\Package\PackageInterface')
|
||||
->getMock();
|
||||
|
||||
return $mock;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue