Skip to content

Commit

Permalink
Fixed case for empty folder
Browse files Browse the repository at this point in the history
  • Loading branch information
yosmanyga committed Nov 8, 2014
1 parent 08bebab commit 5321741
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Symfony/Component/Filesystem/Filesystem.php
Expand Up @@ -388,6 +388,10 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
$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());

Expand Down
15 changes: 15 additions & 0 deletions src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
Expand Up @@ -845,6 +845,21 @@ public function testMirrorCopiesFilesAndDirectoriesRecursively()
$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();
Expand Down

0 comments on commit 5321741

Please sign in to comment.