Skip to content

Commit 11a676d

Browse files
committed
[Filesystem] Added unit tests for mirror method.
1 parent 8c94069 commit 11a676d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,28 @@ public function providePathsForMakePathRelative()
441441
return $paths;
442442
}
443443

444+
public function testMirrorCopiesFilesAndDirectoriesRecursively()
445+
{
446+
$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
447+
$directory = $sourcePath.'directory'.DIRECTORY_SEPARATOR;
448+
$file1 = $directory.'file1';
449+
$file2 = $sourcePath.'file2';
450+
451+
mkdir($sourcePath);
452+
mkdir($directory);
453+
file_put_contents($file1, 'FILE1');
454+
file_put_contents($file2, 'FILE2');
455+
456+
$targetPath = $this->workspace.DIRECTORY_SEPARATOR.'target'.DIRECTORY_SEPARATOR;
457+
458+
$this->filesystem->mirror($sourcePath, $targetPath);
459+
460+
$this->assertTrue(is_dir($targetPath));
461+
$this->assertTrue(is_dir($targetPath.'directory'));
462+
$this->assertFileEquals($file1, $targetPath.'directory'.DIRECTORY_SEPARATOR.'file1');
463+
$this->assertFileEquals($file2, $targetPath.'file2');
464+
}
465+
444466
/**
445467
* @dataProvider providePathsForIsAbsolutePath
446468
*/

0 commit comments

Comments
 (0)