8000 [Filesystem] symlink use RealPath instead LinkTarget by aitboudad · Pull Request #12761 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Filesystem] symlink use RealPath instead LinkTarget #12761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.

Loading

Diff view
Diff view
Prev Previous commit
Added unit-tests.
  • Loading branch information
aitboudad committed Nov 30, 2014
commit 8b03314261d8186594735ba502179613b384352a
25 changes: 25 additions & 0 deletions src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,31 @@ public function testMirrorCopiesLinkedDirectoryContents()
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
}

public function testMirrorCopiesRelativeLinkedContents()
{
$this->markAsSkippedIfSymlinkIsMissing();

$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
$oldPath = getcwd();

mkdir($sourcePath.'nested/', 0777, true);
file_put_contents($sourcePath.'/nested/file1.txt', 'FILE1');
// Note: Create relative symlink
chdir($sourcePath);
symlink('nested', 'link1');

chdir($oldPath);

$targetPath = $this->workspace.DIRECTORY_SEPARATOR.'target'.DIRECTORY_SEPARATOR;

$this->filesystem->mirror($sourcePath, $targetPath);

$this->assertTrue(is_dir($targetPath));
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.DIRECTORY_SEPARATOR.'link1/file1.txt');
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
$this->assertEquals($sourcePath.'nested', readlink($targetPath.DIRECTORY_SEPARATOR.'link1'));
}

/**
* @dataProvider providePathsForIsAbsolutePath
*/
Expand Down
0