mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-08 00:52:01 +01:00
Fix: Pb in json function for objects
This commit is contained in:
@@ -224,10 +224,81 @@ class FilesLibTest extends PHPUnit_Framework_TestCase
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testDolMimeType
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function testDolMimeType()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
// file.png
|
||||
$result=dol_mimetype('file.png','',0);
|
||||
$this->assertEquals('image/png',$result);
|
||||
$result=dol_mimetype('file.png','',1);
|
||||
$this->assertEquals('png',$result);
|
||||
$result=dol_mimetype('file.png','',2);
|
||||
$this->assertEquals('image.png',$result);
|
||||
$result=dol_mimetype('file.png','',3);
|
||||
$this->assertEquals('',$result);
|
||||
// file.odt
|
||||
$result=dol_mimetype('file.odt','',0);
|
||||
$this->assertEquals('application/vnd.oasis.opendocument.text',$result);
|
||||
$result=dol_mimetype('file.odt','',1);
|
||||
$this->assertEquals('vnd.oasis.opendocument.text',$result);
|
||||
$result=dol_mimetype('file.odt','',2);
|
||||
$this->assertEquals('ooffice.png',$result);
|
||||
$result=dol_mimetype('file.odt','',3);
|
||||
$this->assertEquals('',$result);
|
||||
// file.php
|
||||
$result=dol_mimetype('file.php','',0);
|
||||
$this->assertEquals('text/plain',$result);
|
||||
$result=dol_mimetype('file.php','',1);
|
||||
$this->assertEquals('plain',$result);
|
||||
$result=dol_mimetype('file.php','',2);
|
||||
$this->assertEquals('php.png',$result);
|
||||
$result=dol_mimetype('file.php','',3);
|
||||
$this->assertEquals('php',$result);
|
||||
// file.php.noexe
|
||||
$result=dol_mimetype('file.php.noexe','',0);
|
||||
$this->assertEquals('text/plain',$result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testDolDeleteDir
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function testDolDeleteDir()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$dirout=$conf->admin->dir_temp.'/test';
|
||||
|
||||
$count=0;
|
||||
$result=dol_delete_dir_recursive($dirout,$count,1); // If it has no permission to delete, it will fails as if dir does not exists, so we can't test it
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(0,$result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testDolCopyMoveDelete
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @depends testDolDeleteDir
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testDolCopyMoveDelete()
|
||||
{
|
||||
@@ -272,55 +343,13 @@ class FilesLibTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testDolMimeType
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function testDolMimeType()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
// file.png
|
||||
$result=dol_mimetype('file.png','',0);
|
||||
$this->assertEquals('image/png',$result);
|
||||
$result=dol_mimetype('file.png','',1);
|
||||
$this->assertEquals('png',$result);
|
||||
$result=dol_mimetype('file.png','',2);
|
||||
$this->assertEquals('image.png',$result);
|
||||
$result=dol_mimetype('file.png','',3);
|
||||
$this->assertEquals('',$result);
|
||||
// file.odt
|
||||
$result=dol_mimetype('file.odt','',0);
|
||||
$this->assertEquals('application/vnd.oasis.opendocument.text',$result);
|
||||
$result=dol_mimetype('file.odt','',1);
|
||||
$this->assertEquals('vnd.oasis.opendocument.text',$result);
|
||||
$result=dol_mimetype('file.odt','',2);
|
||||
$this->assertEquals('ooffice.png',$result);
|
||||
$result=dol_mimetype('file.odt','',3);
|
||||
$this->assertEquals('',$result);
|
||||
// file.php
|
||||
$result=dol_mimetype('file.php','',0);
|
||||
$this->assertEquals('text/plain',$result);
|
||||
$result=dol_mimetype('file.php','',1);
|
||||
$this->assertEquals('plain',$result);
|
||||
$result=dol_mimetype('file.php','',2);
|
||||
$this->assertEquals('php.png',$result);
|
||||
$result=dol_mimetype('file.php','',3);
|
||||
$this->assertEquals('php',$result);
|
||||
// file.php.noexe
|
||||
$result=dol_mimetype('file.php.noexe','',0);
|
||||
$this->assertEquals('text/plain',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testDolCompressUnCompress
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @depends testDolCopyMoveDelete
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testDolCompressUnCompress()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user