[Filesystem] Fixed a bug in remove being unable to remove symlinks to unexisting file or directory.
This commit is contained in:
parent
11a676d672
commit
d4243a28b6
@ -88,7 +88,7 @@ class Filesystem
|
||||
$files = iterator_to_array($this->toIterator($files));
|
||||
$files = array_reverse($files);
|
||||
foreach ($files as $file) {
|
||||
if (!file_exists($file)) {
|
||||
if (!file_exists($file) && !is_link($file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -297,6 +297,22 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue(!is_dir($basePath.'dir'));
|
||||
}
|
||||
|
||||
public function testRemoveCleansInvalidLinks()
|
||||
{
|
||||
$this->markAsSkippeIfSymlinkIsMissing();
|
||||
|
||||
$basePath = $this->workspace.DIRECTORY_SEPARATOR.'directory'.DIRECTORY_SEPARATOR;
|
||||
|
||||
mkdir($basePath);
|
||||
mkdir($basePath.'dir');
|
||||
// create symlink to unexisting file
|
||||
symlink($basePath.'file', $basePath.'link');
|
||||
|
||||
$this->filesystem->remove($basePath);
|
||||
|
||||
$this->assertTrue(!is_dir($basePath));
|
||||
}
|
||||
|
||||
public function testChmodChangesFileMode()
|
||||
{
|
||||
$file = $this->workspace.DIRECTORY_SEPARATOR.'file';
|
||||
|
Reference in New Issue
Block a user