Skip to content

Commit

Permalink
[FileSystem] remove symlinks under windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Trapman committed Jun 13, 2012
1 parent e1f7c29 commit e1a5395
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Filesystem.php
Expand Up @@ -94,7 +94,9 @@ public function remove($files)

if (is_dir($file) && !is_link($file)) {
$this->remove(new \FilesystemIterator($file));

rmdir($file);
} elseif(is_dir($file) && is_link($file)) {
// https://bugs.php.net/bug.php?id=52176 windows thinks symlinks are directories
rmdir($file);
} else {
unlink($file);
Expand Down
14 changes: 14 additions & 0 deletions Tests/FilesystemTest.php
Expand Up @@ -421,6 +421,20 @@ public function testSymlink()
$this->assertTrue(is_link($link));
$this->assertEquals($file, readlink($link));
}

/**
* @depends testSymlink
*/
public function testRemoveSymlink()
{
$this->markAsSkippedIfSymlinkIsMissing();

$link = $this->workspace.DIRECTORY_SEPARATOR.'link';

$this->filesystem->remove($link);

$this->assertTrue(!is_link($link));
}

public function testSymlinkIsOverwrittenIfPointsToDifferentTarget()
{
Expand Down

0 comments on commit e1a5395

Please sign in to comment.