1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-10 00:53:06 +00:00

Fix broken junctions leading to installation failure on Windows (#11550)

This commit is contained in:
Attia A. Ahmed 2023-07-21 11:58:54 +03:00 committed by Jordi Boggiano
parent 4b210d916e
commit ce876e7a6f
No known key found for this signature in database
GPG key ID: 7BBD42C429EC80BC
2 changed files with 39 additions and 0 deletions

View file

@ -12,6 +12,7 @@
namespace Composer\Test\Util;
use Composer\Util\Platform;
use Composer\Util\Filesystem;
use Composer\Test\TestCase;
@ -317,6 +318,38 @@ class FilesystemTest extends TestCase
$this->assertDirectoryDoesNotExist($junction, $junction . ' is not a directory');
}
public function testOverrideJunctions(): void
{
if (!Platform::isWindows()) {
$this->markTestSkipped('Only runs on windows');
}
@mkdir($this->workingDir.'/real/nesting/testing', 0777, true);
$fs = new Filesystem();
$old_target = $this->workingDir.'/real/nesting/testing';
$target = $this->workingDir.'/real/../real/nesting';
$junction = $this->workingDir.'/junction';
// Override non-broken junction
$fs->junction($old_target, $junction);
$fs->junction($target, $junction);
$this->assertTrue($fs->isJunction($junction), $junction.': is a junction');
$this->assertTrue($fs->isJunction($target.'/../../junction'), $target.'/../../junction: is a junction');
//Remove junction
$this->assertTrue($fs->removeJunction($junction), $junction . ' has been removed');
// Override broken junction
$fs->junction($old_target, $junction);
$fs->removeDirectory($old_target);
$fs->junction($target, $junction);
$this->assertTrue($fs->isJunction($junction), $junction.': is a junction');
$this->assertTrue($fs->isJunction($target.'/../../junction'), $target.'/../../junction: is a junction');
}
public function testCopy(): void
{
@mkdir($this->workingDir . '/foo/bar', 0777, true);