Skip to content

Commit

Permalink
use parent unlink class for file helper
Browse files Browse the repository at this point in the history
  • Loading branch information
nadar committed Apr 1, 2019
1 parent 7e53169 commit fd689db
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 6 additions & 4 deletions core/helpers/FileHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,12 @@ public static function getFileContent($fileName)
*/
public static function unlink($file)
{
// default unlink
if (@unlink($file)) {
return true;
}
// no errors should be thrown, return false instead.
try {
if (parent::unlink($file)) {
return true;
}
} catch (\Exception $e) {}

// try to force symlinks
if (is_link($file)) {
Expand Down
5 changes: 5 additions & 0 deletions tests/core/helpers/FileHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public function testGetFileContent()

$this->assertFalse(FileHelper::getFileContent('doesNotExist.txt'));
}

public function testUnlink()
{
$this->assertFalse(FileHelper::unlink('doesnotexsts.jpg'));
}

public function testClassInfo()
{
Expand Down

0 comments on commit fd689db

Please sign in to comment.