bug #12436 [Filesystem] Fixed case for empty folder (yosmanyga)
This PR was merged into the 2.3 branch.
Discussion
----------
[Filesystem] Fixed case for empty folder
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
The mirror function should work with an empty folder as source. It should create an empty folder on target path.
Commits
-------
5321741
Fixed case for empty folder
This commit is contained in:
commit
1f55706be9
@ -388,6 +388,10 @@ class Filesystem
|
|||||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir, $flags), \RecursiveIteratorIterator::SELF_FIRST);
|
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir, $flags), \RecursiveIteratorIterator::SELF_FIRST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->exists($originDir)) {
|
||||||
|
$this->mkdir($targetDir);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($iterator as $file) {
|
foreach ($iterator as $file) {
|
||||||
$target = str_replace($originDir, $targetDir, $file->getPathname());
|
$target = str_replace($originDir, $targetDir, $file->getPathname());
|
||||||
|
|
||||||
|
@ -845,6 +845,21 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertFalse($this->filesystem->exists($targetPath.'directory'.DIRECTORY_SEPARATOR.'file1'));
|
$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()
|
public function testMirrorCopiesLinks()
|
||||||
{
|
{
|
||||||
$this->markAsSkippedIfSymlinkIsMissing();
|
$this->markAsSkippedIfSymlinkIsMissing();
|
||||||
|
Reference in New Issue
Block a user