Merge remote-tracking branch 'wookieb/installer_dry_run'
commit
8dcb75080e
|
@ -53,10 +53,8 @@ class LibraryInstaller implements InstallerInterface
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
|
|
||||||
$this->filesystem = new Filesystem();
|
$this->filesystem = new Filesystem();
|
||||||
$this->filesystem->ensureDirectoryExists($vendorDir);
|
$this->vendorDir = rtrim($vendorDir, '/');
|
||||||
$this->filesystem->ensureDirectoryExists($binDir);
|
$this->binDir = rtrim($binDir, '/');
|
||||||
$this->vendorDir = realpath($vendorDir);
|
|
||||||
$this->binDir = realpath($binDir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,6 +80,9 @@ class LibraryInstaller implements InstallerInterface
|
||||||
{
|
{
|
||||||
$downloadPath = $this->getInstallPath($package);
|
$downloadPath = $this->getInstallPath($package);
|
||||||
|
|
||||||
|
$this->filesystem->ensureDirectoryExists($this->vendorDir);
|
||||||
|
$this->filesystem->ensureDirectoryExists($this->binDir);
|
||||||
|
|
||||||
// remove the binaries if it appears the package files are missing
|
// remove the binaries if it appears the package files are missing
|
||||||
if (!is_readable($downloadPath) && $this->repository->hasPackage($package)) {
|
if (!is_readable($downloadPath) && $this->repository->hasPackage($package)) {
|
||||||
$this->removeBinaries($package);
|
$this->removeBinaries($package);
|
||||||
|
@ -105,6 +106,9 @@ class LibraryInstaller implements InstallerInterface
|
||||||
|
|
||||||
$downloadPath = $this->getInstallPath($initial);
|
$downloadPath = $this->getInstallPath($initial);
|
||||||
|
|
||||||
|
$this->filesystem->ensureDirectoryExists($this->vendorDir);
|
||||||
|
$this->filesystem->ensureDirectoryExists($this->binDir);
|
||||||
|
|
||||||
$this->removeBinaries($initial);
|
$this->removeBinaries($initial);
|
||||||
$this->downloadManager->update($initial, $target, $downloadPath);
|
$this->downloadManager->update($initial, $target, $downloadPath);
|
||||||
$this->installBinaries($target);
|
$this->installBinaries($target);
|
||||||
|
|
|
@ -22,22 +22,22 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase
|
||||||
private $binDir;
|
private $binDir;
|
||||||
private $dm;
|
private $dm;
|
||||||
private $repository;
|
private $repository;
|
||||||
private $library;
|
|
||||||
private $io;
|
private $io;
|
||||||
|
private $fs;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$fs = new Filesystem;
|
$this->fs = new Filesystem;
|
||||||
|
|
||||||
$this->vendorDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'composer-test-vendor';
|
$this->vendorDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'composer-test-vendor';
|
||||||
if (is_dir($this->vendorDir)) {
|
if (is_dir($this->vendorDir)) {
|
||||||
$fs->removeDirectory($this->vendorDir);
|
$this->fs->removeDirectory($this->vendorDir);
|
||||||
}
|
}
|
||||||
mkdir($this->vendorDir);
|
mkdir($this->vendorDir);
|
||||||
|
|
||||||
$this->binDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'composer-test-bin';
|
$this->binDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'composer-test-bin';
|
||||||
if (is_dir($this->binDir)) {
|
if (is_dir($this->binDir)) {
|
||||||
$fs->removeDirectory($this->binDir);
|
$this->fs->removeDirectory($this->binDir);
|
||||||
}
|
}
|
||||||
mkdir($this->binDir);
|
mkdir($this->binDir);
|
||||||
|
|
||||||
|
@ -52,16 +52,20 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase
|
||||||
->getMock();
|
->getMock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInstallerCreation()
|
public function testInstallerCreationShouldNotCreateVendorDirectory()
|
||||||
{
|
{
|
||||||
$library = new LibraryInstaller($this->vendorDir, $this->binDir, $this->dm, $this->repository, $this->io);
|
$this->fs->removeDirectory($this->vendorDir);
|
||||||
$this->assertTrue(is_dir($this->vendorDir));
|
|
||||||
|
|
||||||
$file = sys_get_temp_dir().'/file';
|
new LibraryInstaller($this->vendorDir, $this->binDir, $this->dm, $this->repository, $this->io);
|
||||||
touch($file);
|
$this->assertFileNotExists($this->vendorDir);
|
||||||
|
}
|
||||||
|
|
||||||
$this->setExpectedException('RuntimeException');
|
public function testInstallerCreationShouldNotCreateBinDirectory()
|
||||||
$library = new LibraryInstaller($file, $this->binDir, $this->dm, $this->repository, $this->io);
|
{
|
||||||
|
$this->fs->removeDirectory($this->binDir);
|
||||||
|
|
||||||
|
new LibraryInstaller($this->vendorDir, $this->binDir, $this->dm, $this->repository, $this->io);
|
||||||
|
$this->assertFileNotExists($this->binDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsInstalled()
|
public function testIsInstalled()
|
||||||
|
@ -79,6 +83,10 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertFalse($library->isInstalled($package));
|
$this->assertFalse($library->isInstalled($package));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testInstallerCreationShouldNotCreateVendorDirectory
|
||||||
|
* @depends testInstallerCreationShouldNotCreateBinDirectory
|
||||||
|
*/
|
||||||
public function testInstall()
|
public function testInstall()
|
||||||
{
|
{
|
||||||
$library = new LibraryInstaller($this->vendorDir, $this->binDir, $this->dm, $this->repository, $this->io);
|
$library = new LibraryInstaller($this->vendorDir, $this->binDir, $this->dm, $this->repository, $this->io);
|
||||||
|
@ -100,8 +108,14 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase
|
||||||
->with($package);
|
->with($package);
|
||||||
|
|
||||||
$library->install($package);
|
$library->install($package);
|
||||||
|
$this->assertFileExists($this->vendorDir, 'Vendor dir should be created');
|
||||||
|
$this->assertFileExists($this->binDir, 'Bin dir should be created');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testInstallerCreationShouldNotCreateVendorDirectory
|
||||||
|
* @depends testInstallerCreationShouldNotCreateBinDirectory
|
||||||
|
*/
|
||||||
public function testUpdate()
|
public function testUpdate()
|
||||||
{
|
{
|
||||||
$library = new LibraryInstaller($this->vendorDir, $this->binDir, $this->dm, $this->repository, $this->io);
|
$library = new LibraryInstaller($this->vendorDir, $this->binDir, $this->dm, $this->repository, $this->io);
|
||||||
|
@ -135,6 +149,8 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase
|
||||||
->with($target);
|
->with($target);
|
||||||
|
|
||||||
$library->update($initial, $target);
|
$library->update($initial, $target);
|
||||||
|
$this->assertFileExists($this->vendorDir, 'Vendor dir should be created');
|
||||||
|
$this->assertFileExists($this->binDir, 'Bin dir should be created');
|
||||||
|
|
||||||
$this->setExpectedException('InvalidArgumentException');
|
$this->setExpectedException('InvalidArgumentException');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue