From 85022945dcd2d06641574e4b686734d369363679 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Thu, 30 Apr 2026 16:34:23 +0200 Subject: [PATCH] Unit test : test changes 10.2 --- unit-test/include/Ajax/ajax_miscTest.php | 36 ++++++++++++++++++-- unit-test/include/class/Acc_DocumentTest.php | 11 ------ unit-test/include/class/Acc_TVATest.php | 4 +-- unit-test/include/class/FacturXTest.php | 5 ++- unit-test/include/class/InvoiceUBL21Test.php | 3 +- 5 files changed, 42 insertions(+), 17 deletions(-) diff --git a/unit-test/include/Ajax/ajax_miscTest.php b/unit-test/include/Ajax/ajax_miscTest.php index f5e94c81e..0113995fc 100644 --- a/unit-test/include/Ajax/ajax_miscTest.php +++ b/unit-test/include/Ajax/ajax_miscTest.php @@ -146,8 +146,9 @@ class Ajax_MiscTest extends TestCase ); $_REQUEST = $_POST = $_GET = $query; + ob_start(); - require NOALYSS_HOME . '/fid.php'; + include NOALYSS_HOME . '/fid.php'; $content = ob_get_contents(); 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"} EOF; - $this->assertEquals($expected, $content, "Incorrect answer"); + $this->assertEquals($expected, $content, "Incorrect answer $content"); // clean card $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"); + } } \ No newline at end of file diff --git a/unit-test/include/class/Acc_DocumentTest.php b/unit-test/include/class/Acc_DocumentTest.php index 53fc2d1f9..109bd431b 100644 --- a/unit-test/include/class/Acc_DocumentTest.php +++ b/unit-test/include/class/Acc_DocumentTest.php @@ -194,17 +194,6 @@ class Acc_DocumentTest extends TestCase { // 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 * @covers Document::generate diff --git a/unit-test/include/class/Acc_TVATest.php b/unit-test/include/class/Acc_TVATest.php index 9bf8bfb3f..15573f0e3 100644 --- a/unit-test/include/class/Acc_TVATest.php +++ b/unit-test/include/class/Acc_TVATest.php @@ -128,7 +128,7 @@ class Acc_TVATest extends TestCase return array( ['S',true,null] ,['Z',true,null] - ,['A',false,""] + ,['A',true,""] ,['K',true,"XX"] ); } @@ -159,7 +159,7 @@ class Acc_TVATest extends TestCase if ( $result != $check) { 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); } } diff --git a/unit-test/include/class/FacturXTest.php b/unit-test/include/class/FacturXTest.php index 0053f65ca..739b92ce4 100644 --- a/unit-test/include/class/FacturXTest.php +++ b/unit-test/include/class/FacturXTest.php @@ -49,6 +49,9 @@ class FacturXTest extends TestCase { function testBuild_Data() { $cn=\Dossier::connect(); $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']; $a_error = $facturx->check_customer_data($customer['card_id']); 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)); } } diff --git a/unit-test/include/class/InvoiceUBL21Test.php b/unit-test/include/class/InvoiceUBL21Test.php index 70b4c647d..8798bc30b 100644 --- a/unit-test/include/class/InvoiceUBL21Test.php +++ b/unit-test/include/class/InvoiceUBL21Test.php @@ -50,6 +50,7 @@ class InvoiceUBL21Test extends TestCase { function testBuild_Data() { $cn = \Dossier::connect(); $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); $customer = $ublinvoice21->get_data()['customer']; $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)); } }