Fixed case for empty folder

This commit is contained in:
Yosmany Garcia 2014-11-08 14:35:51 -05:00
parent 08bebaba2c
commit 5321741ab5
2 changed files with 19 additions and 0 deletions

View File

@ -388,6 +388,10 @@ class Filesystem
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir, $flags), \RecursiveIteratorIterator::SELF_FIRST);
}
if ($this->exists($originDir)) {
$this->mkdir($targetDir);
}
foreach ($iterator as $file) {
$target = str_replace($originDir, $targetDir, $file->getPathname());

View File

@ -845,6 +845,21 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($this->filesystem->exists($targetPath.'directory'.DIRECTORY_SEPARATOR.'file1'));
}
public function testMirrorCreatesEmptyDirectory()
{
$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
mkdir($sourcePath);
$targetPath = $this->workspace.DIRECTORY_SEPARATOR.'target'.DIRECTORY_SEPARATOR;
$this->filesystem->mirror($sourcePath, $targetPath);
$this->assertTrue(is_dir($targetPath));
$this->filesystem->remove($sourcePath);
}
public function testMirrorCopiesLinks()
{
$this->markAsSkippedIfSymlinkIsMissing();