From 7b542731a11e3e5bcf135a6c499281c217932780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Mon, 3 Mar 2014 15:59:11 +0100 Subject: [PATCH 1/3] Made test pessimistic by default The test result was wrong if, for example, the path was wrong. The unlink() function being never called, it returned the default true value even if it didn't remove a file. --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 0af5e917cc5..553d275c466 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -832,7 +832,7 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n $error=0; //print "x".$file." ".$disableglob;exit; - $ok=true; + $ok=false; $file_osencoded=dol_osencode($file); // New filename encoded in OS filesystem encoding charset if (empty($disableglob) && ! empty($file_osencoded)) { From b91d1fa0cac09fa9192e6d7e2674eb3054909ad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Tue, 25 Mar 2014 10:58:35 +0100 Subject: [PATCH 2/3] dol_delete_files(): removed unused variables --- htdocs/core/lib/files.lib.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 553d275c466..c45dbf96927 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -802,7 +802,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable */ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=null) { - global $db, $conf, $user, $langs; + global $langs; global $hookmanager; $langs->load("other"); @@ -829,8 +829,6 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n } else { - $error=0; - //print "x".$file." ".$disableglob;exit; $ok=false; $file_osencoded=dol_osencode($file); // New filename encoded in OS filesystem encoding charset From 7d08c95fcc54fbcb2845ef860c2c9e34b4417ba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Wed, 17 Sep 2014 15:59:34 +0200 Subject: [PATCH 3/3] Updated unit test to reflect dol_delete_file changes --- test/phpunit/FilesLibTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index 4477784ae7d..409816d5f90 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -339,10 +339,9 @@ class FilesLibTest extends PHPUnit_Framework_TestCase print __METHOD__." result=".$result."\n"; $this->assertTrue($result,'delete file'); - // Again to test no error when deleteing a non existing file $result=dol_delete_file($conf->admin->dir_temp.'/file2.csv'); print __METHOD__." result=".$result."\n"; - $this->assertTrue($result,'delete file that does not exists'); + $this->assertFalse($result,'delete file that does not exists'); // Test copy with special char / delete with blob $result=dol_copy($file, $conf->admin->dir_temp.'/file with [x] and é.csv',0,1);