Unit test : test changes 10.2

This commit is contained in:
sparkyx 2026-04-30 16:34:23 +02:00
parent 0fb3ab4973
commit 85022945dc
5 changed files with 42 additions and 17 deletions

View file

@ -146,8 +146,9 @@ class Ajax_MiscTest extends TestCase
); );
$_REQUEST = $_POST = $_GET = $query; $_REQUEST = $_POST = $_GET = $query;
ob_start(); ob_start();
require NOALYSS_HOME . '/fid.php'; include NOALYSS_HOME . '/fid.php';
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
@ -155,10 +156,41 @@ class Ajax_MiscTest extends TestCase
{"flabel":"e_march4_label","name":"Inserted by PHPUNIT-Ajax_MiscTest:createCard_MA1 ","ftva_id":"e_march4_tva_id","tva_id":"210A","fPrice_sale":"e_march4_price","sell":"0","fPrice_purchase":"e_march4_price","buy":"0","answer":"ok"} {"flabel":"e_march4_label","name":"Inserted by PHPUNIT-Ajax_MiscTest:createCard_MA1 ","ftva_id":"e_march4_tva_id","tva_id":"210A","fPrice_sale":"e_march4_price","sell":"0","fPrice_purchase":"e_march4_price","buy":"0","answer":"ok"}
EOF; EOF;
$this->assertEquals($expected, $content, "Incorrect answer"); $this->assertEquals($expected, $content, "Incorrect answer $content");
// clean card // clean card
$this->cleanCard($fiche->id); $this->cleanCard($fiche->id);
} }
public function testComputeQRCODE()
{
$_POST['secret']="QJPJXHOJ77B76WYEFURCSHRMVI7JC7FBRJA2QH34T4SXANVQUDYA";
$_POST['action']="qr_refresh";
ob_start();
include NOALYSS_HOME."/compute.php";
$x= ob_get_contents();
ob_end_clean();
$this->assertTrue($x==floatval($x),"Invalid return $x");
}
public function testCompute1()
{
$_POST=$_REQUEST=$_GET=array (
'gDossier' => DOSSIER,
'c'=>'PORA',
't'=>1,
'p'=>600,
'q'=>1,
'n'=>0,
'other_tax_id' => -1
);
ob_start();
include NOALYSS_HOME."/compute.php";
$content = ob_get_contents();
ob_end_clean();
$expected='{"ctl":0,"htva":600,"tva":126,"tvac":"726.0000","other_tax":0}'."\n";
$this->assertEquals($expected, $content, "Incorrect answer $content");
}
} }

View file

@ -194,17 +194,6 @@ class Acc_DocumentTest extends TestCase {
// return array([1], [2], [3]); // return array([1], [2], [3]);
// } // }
/**
* @testdox description of the test
* @covers Acc_Balance::summary_add
* @depend Acc_Balance::summary_init
* @backupGlobals enabled
* @dataProvider dataExample
* @global $g_connection
*/
function testFunction() {
}
/** /**
* @testdox Test the standard invoice, check file * @testdox Test the standard invoice, check file
* @covers Document::generate * @covers Document::generate

View file

@ -128,7 +128,7 @@ class Acc_TVATest extends TestCase
return array( return array(
['S',true,null] ['S',true,null]
,['Z',true,null] ,['Z',true,null]
,['A',false,""] ,['A',true,""]
,['K',true,"XX"] ,['K',true,"XX"]
); );
} }
@ -159,7 +159,7 @@ class Acc_TVATest extends TestCase
if ( $result != $check) if ( $result != $check)
{ {
print "Error for $peppopl_code\n"; print "Error for $peppopl_code\n";
print_r($tva_rate_mtable->aerror); print_r($tva_rate_mtable->get_aerror());
$this->display_error($tva_rate_mtable); $this->display_error($tva_rate_mtable);
} }
} }

View file

@ -49,6 +49,9 @@ class FacturXTest extends TestCase {
function testBuild_Data() { function testBuild_Data() {
$cn=\Dossier::connect(); $cn=\Dossier::connect();
$facturx=new \Noalyss\XMLDocument\FacturX($cn); $facturx=new \Noalyss\XMLDocument\FacturX($cn);
$data=$facturx->get_data() ;
$this->assertTrue($data == []
," Build Data fails : get null value");
} }
@ -137,6 +140,6 @@ class FacturXTest extends TestCase {
$customer=$facturx->get_data()['customer']; $customer=$facturx->get_data()['customer'];
$a_error = $facturx->check_customer_data($customer['card_id']); $a_error = $facturx->check_customer_data($customer['card_id']);
print_r($a_error); print_r($a_error);
$this->assertTrue(count($a_error)==6, "nb of error incorrect ,expected 6, received = ".print_r($a_error,true)); $this->assertTrue(count($a_error)==5, "nb of error incorrect (JR_INTERNAL=V000002),expected 5, received = ".print_r($a_error,true));
} }
} }

View file

@ -50,6 +50,7 @@ class InvoiceUBL21Test extends TestCase {
function testBuild_Data() { function testBuild_Data() {
$cn = \Dossier::connect(); $cn = \Dossier::connect();
$ublinvoice21 = new \Noalyss\XMLDocument\InvoiceUBL21($cn); $ublinvoice21 = new \Noalyss\XMLDocument\InvoiceUBL21($cn);
$this->assertTrue($ublinvoice21->get_data()==[],"Data is not empty");
} }
/** /**
@ -170,6 +171,6 @@ class InvoiceUBL21Test extends TestCase {
$ublinvoice21->build_data(2); $ublinvoice21->build_data(2);
$customer = $ublinvoice21->get_data()['customer']; $customer = $ublinvoice21->get_data()['customer'];
$a_error=$ublinvoice21->check_customer_data($customer['card_id']); $a_error=$ublinvoice21->check_customer_data($customer['card_id']);
$this->assertTrue(count($a_error) ==6 , " nb of errors incorrect ".print_r($a_error,true)); $this->assertTrue(count($a_error) ==7 , " nb of errors incorrect ".print_r($a_error,true));
} }
} }