part2 of test
This commit is contained in:
parent
f43f2ab670
commit
5c757c30be
@ -559,4 +559,72 @@ class FilesLibTest extends PHPUnit\Framework\TestCase
|
||||
$user->rights->facture->lire = $savpermlire;
|
||||
$user->rights->facture->creer = $savpermcreer;
|
||||
}
|
||||
|
||||
/**
|
||||
* testDolDirMove
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDolDirMove()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
// To test a move of empty directory that should work
|
||||
$dirsrcpath = $conf->admin->dir_temp.'/directory';
|
||||
$dirdestpath = $conf->admin->dir_temp.'/directory2';
|
||||
$file=dirname(__FILE__).'/Example_import_company_1.csv';
|
||||
dol_mkdir($dirsrcpath);
|
||||
dol_delete_dir_recursive($dirdestpath, 0, 1);
|
||||
$result=dol_move_dir($dirsrcpath, $dirdestpath, 1, 1, 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertTrue($result, 'move of directory with empty directory');
|
||||
|
||||
// To test a move on existing directory with overwrite
|
||||
dol_mkdir($dirsrcpath);
|
||||
$result=dol_move_dir($dirsrcpath, $dirdestpath, 1, 1, 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertTrue($result, 'move of directory on existing directory with empty directory');
|
||||
|
||||
// To test a move on existing directory without overwrite
|
||||
dol_mkdir($dirsrcpath);
|
||||
$result=dol_move_dir($dirsrcpath, $dirdestpath, 0, 1, 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertFalse($result, 'move of directory on existing directory without overwrite');
|
||||
|
||||
// To test a move with a file to rename in src directory
|
||||
dol_mkdir($dirsrcpath);
|
||||
dol_delete_dir_recursive($dirdestpath, 0, 1);
|
||||
dol_copy($file, $dirsrcpath.'/directory_file.csv');
|
||||
$result=dol_move_dir($dirsrcpath, $dirdestpath, 1, 1, 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertTrue($result, 'move of directory with file in directory');
|
||||
|
||||
// To test a move without a file to rename in src directory
|
||||
dol_mkdir($dirsrcpath);
|
||||
dol_delete_dir_recursive($dirdestpath, 0, 1);
|
||||
dol_copy($file, $dirsrcpath.'/file.csv');
|
||||
$result=dol_move_dir($dirsrcpath, $dirdestpath, 1, 1, 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertTrue($result, 'move of directory with file whitout rename needed in directory');
|
||||
|
||||
// To test a move with a directory to rename in src directory
|
||||
dol_mkdir($dirsrcpath);
|
||||
dol_delete_dir_recursive($dirdestpath, 0, 1);
|
||||
dol_mkdir($dirsrcpath.'/directory');
|
||||
$result=dol_move_dir($dirsrcpath, $dirdestpath, 1, 1, 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertTrue($result, 'move of directory with file with rename needed in directory');
|
||||
|
||||
// To test a move without a directory to rename in src directory
|
||||
dol_mkdir($dirsrcpath);
|
||||
dol_delete_dir_recursive($dirdestpath, 0, 1);
|
||||
dol_mkdir($dirsrcpath.'/notorename');
|
||||
$result=dol_move_dir($dirsrcpath, $dirdestpath, 1, 1, 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertTrue($result, 'move of directory with directory whitout rename needed in directory');
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user