-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from gbell12/symlink_fix
Fix problem in remove when broken symlinks exist
- Loading branch information
Showing
3 changed files
with
42 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace deit\filesystem; | ||
|
||
/** | ||
* Filesystem test | ||
* @author Greg Bell <[email protected]> | ||
*/ | ||
|
||
class FilesystemTest extends \PHPUnit_Framework_TestCase { | ||
|
||
public function rmdir_recursive($dir) { | ||
foreach(scandir($dir) as $file) { | ||
if ('.' === $file || '..' === $file) continue; | ||
if (is_dir("$dir/$file")) rmdir_recursive("$dir/$file"); | ||
else unlink("$dir/$file"); | ||
} | ||
rmdir($dir); | ||
} | ||
|
||
public function test_symlink_removal() { | ||
|
||
$test_dir = 'tests/test-data/symlinks'; | ||
$test_link = $test_dir . '/points_nowhere'; | ||
|
||
if ( is_dir($test_dir) ) { | ||
$this->rmdir_recursive( $test_dir ); | ||
} | ||
mkdir( $test_dir ); | ||
symlink( "does_not_exist", $test_link ); | ||
|
||
$fs = new Filesystem(); | ||
$fs->remove( $test_dir ); | ||
$this->assertFalse ( is_link($test_link) || is_file($test_link) ); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters