mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Fix handling of metapackages with null paths, and handling of paths which do not have a shortest-path and require an absolute path to be addressed
This commit is contained in:
parent
518b44a810
commit
3fe4f84a76
4 changed files with 48 additions and 10 deletions
|
@ -12,6 +12,7 @@
|
|||
|
||||
namespace Composer\Test\Repository;
|
||||
|
||||
use Composer\Package\RootPackageInterface;
|
||||
use Composer\Repository\FilesystemRepository;
|
||||
use Composer\Test\TestCase;
|
||||
use Composer\Json\JsonFile;
|
||||
|
@ -157,12 +158,34 @@ class FilesystemRepositoryTest extends TestCase
|
|||
$pkg = $this->getPackage('c/c', '3.0');
|
||||
$repository->addPackage($pkg);
|
||||
|
||||
$pkg = $this->getPackage('meta/package', '3.0');
|
||||
$pkg->setType('metapackage');
|
||||
$repository->addPackage($pkg);
|
||||
|
||||
$im = $this->getMockBuilder('Composer\Installer\InstallationManager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$im->expects($this->any())
|
||||
->method('getInstallPath')
|
||||
->will($this->returnValue('/foo/bar/vendor/woop/woop'));
|
||||
->will($this->returnCallback(function ($package) use ($dir) {
|
||||
// check for empty paths handling
|
||||
if ($package->getType() === 'metapackage') {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($package->getName() === 'c/c') {
|
||||
// check for absolute paths
|
||||
return '/foo/bar/vendor/c/c';
|
||||
}
|
||||
|
||||
// check for cwd
|
||||
if ($package instanceof RootPackageInterface) {
|
||||
return $dir;
|
||||
}
|
||||
|
||||
// check for relative paths
|
||||
return 'vendor/'.$package->getName();
|
||||
}));
|
||||
|
||||
$repository->write(true, $im);
|
||||
$this->assertSame(require __DIR__.'/Fixtures/installed.php', require $dir.'/installed.php');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue