Fix: avoid phpunit warning
This commit is contained in:
parent
b5d70ad17f
commit
bc2280e4ab
@ -476,7 +476,7 @@ class Export
|
|||||||
require_once $dir.$file;
|
require_once $dir.$file;
|
||||||
$objmodel = new $classname($this->db);
|
$objmodel = new $classname($this->db);
|
||||||
|
|
||||||
if ($sqlquery) $sql = $sqlquery;
|
if (! empty($sqlquery)) $sql = $sqlquery;
|
||||||
else $sql=$this->build_sql($indice, $array_selected, $array_filterValue, $array_filtered);
|
else $sql=$this->build_sql($indice, $array_selected, $array_filterValue, $array_filtered);
|
||||||
|
|
||||||
// Run the sql
|
// Run the sql
|
||||||
|
|||||||
@ -144,21 +144,71 @@ class ExportTest extends PHPUnit_Framework_TestCase
|
|||||||
$model='csv';
|
$model='csv';
|
||||||
|
|
||||||
// Build export file
|
// Build export file
|
||||||
$result=$objexport->build_file($user, $model, $datatoexport, $array_selected, $sql);
|
$result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), array(), $sql);
|
||||||
$expectedresult=1;
|
$expectedresult=1;
|
||||||
$this->assertEquals($result,$expectedresult);
|
$this->assertEquals($result,$expectedresult);
|
||||||
|
|
||||||
$model='tsv';
|
$model='tsv';
|
||||||
|
|
||||||
// Build export file
|
// Build export file
|
||||||
$result=$objexport->build_file($user, $model, $datatoexport, $array_selected, $sql);
|
$result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), array(), $sql);
|
||||||
$expectedresult=1;
|
$expectedresult=1;
|
||||||
$this->assertEquals($result,$expectedresult);
|
$this->assertEquals($result,$expectedresult);
|
||||||
|
|
||||||
$model='excel';
|
$model='excel';
|
||||||
|
|
||||||
// Build export file
|
// Build export file
|
||||||
$result=$objexport->build_file($user, $model, $datatoexport, $array_selected, $sql);
|
$result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), array(), $sql);
|
||||||
|
$expectedresult=1;
|
||||||
|
$this->assertEquals($result,$expectedresult);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test filtered export function
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testExportFilteredExport()
|
||||||
|
{
|
||||||
|
global $conf,$user,$langs,$db;
|
||||||
|
|
||||||
|
$sql = "SELECT f.facnumber as f_facnumber, f.amount as f_amount, f.total as f_total, f.tva as f_tva FROM ".MAIN_DB_PREFIX."facture f";
|
||||||
|
|
||||||
|
$objexport=new Export($db);
|
||||||
|
//$objexport->load_arrays($user,$datatoexport);
|
||||||
|
|
||||||
|
// Define properties
|
||||||
|
$datatoexport='test';
|
||||||
|
$array_selected = array("f.facnumber"=>1, "f.amount"=>2, "f.total"=>3, "f.tva"=>4);
|
||||||
|
$array_export_fields = array("f.facnumber"=>"FacNumber", "f.amount"=>"FacAmount", "f.total"=>"FacTotal", "f.tva"=>"FacVat");
|
||||||
|
$array_filtervalue = array("f.amount" => ">100");
|
||||||
|
$array_filtered = array("f.amount" => 1);
|
||||||
|
$array_alias = array("f_facnumber"=>"facnumber", "f_amount"=>"amount", "f_total"=>"total", "f_tva"=>"tva");
|
||||||
|
$objexport->array_export_fields[0]=$array_export_fields;
|
||||||
|
$objexport->array_export_alias[0]=$array_alias;
|
||||||
|
|
||||||
|
dol_mkdir($conf->export->dir_temp);
|
||||||
|
|
||||||
|
$model='csv';
|
||||||
|
|
||||||
|
// Build export file
|
||||||
|
$result=$objexport->build_file($user, $model, $datatoexport, $array_selected, $array_filtervalue, $array_filtered, $sql);
|
||||||
|
$expectedresult=1;
|
||||||
|
$this->assertEquals($result,$expectedresult);
|
||||||
|
|
||||||
|
$model='tsv';
|
||||||
|
|
||||||
|
// Build export file
|
||||||
|
$result=$objexport->build_file($user, $model, $datatoexport, $array_selected, $array_filtervalue, $array_filtered, $sql);
|
||||||
|
$expectedresult=1;
|
||||||
|
$this->assertEquals($result,$expectedresult);
|
||||||
|
|
||||||
|
$model='excel';
|
||||||
|
|
||||||
|
// Build export file
|
||||||
|
$result=$objexport->build_file($user, $model, $datatoexport, $array_selected, $array_filtervalue, $array_filtered, $sql);
|
||||||
$expectedresult=1;
|
$expectedresult=1;
|
||||||
$this->assertEquals($result,$expectedresult);
|
$this->assertEquals($result,$expectedresult);
|
||||||
|
|
||||||
@ -183,7 +233,7 @@ class ExportTest extends PHPUnit_Framework_TestCase
|
|||||||
$result=$objexport->load_arrays($user,$datatoexport);
|
$result=$objexport->load_arrays($user,$datatoexport);
|
||||||
|
|
||||||
// Build export file
|
// Build export file
|
||||||
$result=$objexport->build_file($user, $model, $datatoexport, $array_selected, $sql);
|
$result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), array(), $sql);
|
||||||
$expectedresult=1;
|
$expectedresult=1;
|
||||||
$this->assertEquals($result,$expectedresult);
|
$this->assertEquals($result,$expectedresult);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user