Merge branch '250826-e-einvoice' into unstable
* 250826-e-einvoice: (29 commits) Update VENDOR : remove useless Factur-X norme 3 (May 15th, 2025) E-INVOICE : if upload an XML file than the embedded document will be saved separately, if there is no embedded document a standard document with info from XML will be generated E-INVOICE , when loading a XML , the file is splitted into a PDF and XML XMLInvoiceReader : extract information from XML E-INVOICE : corrige PriceAmount E-INVOICE : show the XML to download Database: upload file function E-INVOICE : export XML if exists from ledger_detail_bottom E-INVOICE : create standard invoice if not convert E-INVOICE: small bugs UBL21 E-INVOICE: negative amount e-invoice : add communication , bank and buyer reference e-invoice : display errors if cannot be created Typo : space quantity PHPUNIT : adapt 12.3 E-INVOICE: check data before generating E-INVOICE: add missing for Belgium : BuyerReference and Due_Date E-INVOICE: add code quantity E-INVOICE : add AdditionalDocument XMLInvoice adapt currency ...
This commit is contained in:
commit
9898434767
169 changed files with 3614 additions and 15659 deletions
125
unit-test/include/class/Acc_DocumentTest.php
Normal file
125
unit-test/include/class/Acc_DocumentTest.php
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*
|
||||
* Author : Dany De Bontridder danydb@noalyss.eu
|
||||
* Copyright (C) 2025 Dany De Bontridder <dany@alchimerys.be>
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief noalyss
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
require DIRTEST . '/global.php';
|
||||
|
||||
/**
|
||||
* @testdox Class xxx : used for ...
|
||||
* @backupGlobals enabled
|
||||
* @coversDefaultClass
|
||||
*/
|
||||
class Acc_DocumentTest extends TestCase {
|
||||
|
||||
/**
|
||||
* @var Fiche
|
||||
*/
|
||||
protected $object;
|
||||
protected $connection;
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test method is executed.
|
||||
*/
|
||||
protected function setUp(): void {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test method is executed.
|
||||
*/
|
||||
protected function tearDown(): void {
|
||||
/**
|
||||
* example
|
||||
* if ( ! is_object($this->object->fiche_def)) return;
|
||||
* include_once DIRTEST.'/global.php';
|
||||
* $g_connection=Dossier::connect();
|
||||
* $sql=new ArrayObject();
|
||||
* $sql->append("delete from fiche_detail where f_id in (select f_id from fiche where fd_id =\$1 )");
|
||||
* $sql->append("delete from fiche where f_id not in (select f_id from fiche_detail where \$1=\$1)");
|
||||
* $sql->append("delete from jnt_fic_attr where fd_id = \$1 ");
|
||||
* $sql->append("delete from fiche_def where fd_id = \$1");
|
||||
* foreach ($sql as $s) {
|
||||
* $g_connection->exec_sql($s,[$this->object->fiche_def->id]);
|
||||
* }
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* the setUpBeforeClass() template methods is called before the first test of the test case
|
||||
* class is run
|
||||
*/
|
||||
public static function setUpBeforeClass(): void {
|
||||
// include 'global.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Data simulation
|
||||
|
||||
* @return array
|
||||
*/
|
||||
function dataExample() {
|
||||
return array(
|
||||
['0A', 4]
|
||||
, ['0B', 6]
|
||||
, [6, 6]
|
||||
, ['NONE', -1]
|
||||
, [14, -1]
|
||||
, [" ", -1]
|
||||
, [null, -1]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDownAfterClass() template methods is calleafter the last test of the test case class is run,
|
||||
*
|
||||
*/
|
||||
static function tearDownAfterClass(): void {
|
||||
// include 'global.php';
|
||||
}
|
||||
|
||||
//
|
||||
// public function dataExample()
|
||||
// {
|
||||
// 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() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
/**
|
||||
* @backupGlobals enabled
|
||||
* @coversDefaultClass \Acc_Payment
|
||||
|
|
@ -84,7 +84,7 @@ class Acc_TVATest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
function dataCheck() {
|
||||
static function dataCheck() {
|
||||
return array(
|
||||
['abc',true]
|
||||
,['13A',true]
|
||||
|
|
@ -100,6 +100,7 @@ class Acc_TVATest extends TestCase
|
|||
* @dataProvider dataCheck
|
||||
* @return void
|
||||
*/
|
||||
#[DataProvider('dataCheck')]
|
||||
function testCheck($tva_code,$result)
|
||||
{
|
||||
$cn=\Dossier::connect();
|
||||
|
|
@ -117,7 +118,7 @@ class Acc_TVATest extends TestCase
|
|||
$this->assertTrue($result==$check," erreur pour $tva_code ");
|
||||
$this->display_error($tva_rate_mtable);
|
||||
}
|
||||
function dataBuild() {
|
||||
static function dataBuild() {
|
||||
return array(
|
||||
['0A',4]
|
||||
,['0B',6]
|
||||
|
|
@ -133,6 +134,7 @@ class Acc_TVATest extends TestCase
|
|||
* @dataProvider dataBuild
|
||||
* @return void
|
||||
*/
|
||||
#[DataProvider('dataBuild')]
|
||||
function testBuild($tva_code,$result)
|
||||
{
|
||||
$cn=\Dossier::connect();
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ use PHPUnit\Framework\TestCase;
|
|||
*/
|
||||
require DIRTEST . '/global.php';
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
/**
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
|
|
@ -150,21 +152,7 @@ class DocumentTest extends TestCase {
|
|||
$cn->commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*/
|
||||
protected function setUp(): void {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
protected function tearDown(): void {
|
||||
|
||||
}
|
||||
|
||||
|
||||
function testBlank() {
|
||||
$cn = Dossier::connect();
|
||||
|
|
@ -266,10 +254,10 @@ class DocumentTest extends TestCase {
|
|||
$document->d_id = $d_id;
|
||||
$document->get();
|
||||
}
|
||||
return $document;
|
||||
return $document;
|
||||
}
|
||||
|
||||
function dataReplace() {
|
||||
static function dataReplace() {
|
||||
return array(
|
||||
["CUST_NAME", "Client 2"],
|
||||
["SOLDE", 27.29],
|
||||
|
|
@ -285,6 +273,7 @@ class DocumentTest extends TestCase {
|
|||
* @backupGlobals enabled
|
||||
* @dataProvider dataReplace
|
||||
*/
|
||||
#[DataProvider('dataReplace')]
|
||||
function testReplace2($tag_name, $value) {
|
||||
require "global.php";
|
||||
static $request = null;
|
||||
|
|
@ -303,7 +292,7 @@ class DocumentTest extends TestCase {
|
|||
$this->assertEquals($name, $value, $tag_name." fails");
|
||||
}
|
||||
|
||||
function dataBalance()
|
||||
static function dataBalance()
|
||||
{
|
||||
return array(
|
||||
['CLIENT1',27.29, 4204.14],
|
||||
|
|
@ -316,6 +305,7 @@ class DocumentTest extends TestCase {
|
|||
|
||||
* @dataProvider dataBalance
|
||||
*/
|
||||
#[DataProvider('dataBalance')]
|
||||
function testBalance($quickcode,$balance_report,$balance_noreport)
|
||||
{
|
||||
require "global.php";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
define('USE_ID', 999999);
|
||||
define('USE_FIRST_NAME', 'Unit test');
|
||||
define('USE_NAME', 'UNIT');
|
||||
|
|
@ -187,7 +187,7 @@ class NoalyssUserTest extends TestCase
|
|||
// check his removal
|
||||
$this->assertEquals($cn->get_value('select count(*) from profile_user where user_name=$1',array('unknown/user')),0);
|
||||
}
|
||||
public function dataPeriode()
|
||||
public static function dataPeriode()
|
||||
{
|
||||
return array(
|
||||
[92],
|
||||
|
|
@ -204,6 +204,7 @@ class NoalyssUserTest extends TestCase
|
|||
* @param type $p_id periode id
|
||||
* @dataProvider dataPeriode
|
||||
*/
|
||||
#[DataProvider('dataPeriode')]
|
||||
public function testPeriode($p_id)
|
||||
{
|
||||
$this->object=new Noalyss_user(Dossier::connect(), USE_ID);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
/**
|
||||
* Generated by PHPUnit_SkeletonGenerator on 2017-11-26 at 11:24:04.
|
||||
*/
|
||||
|
|
@ -234,7 +234,7 @@ class Acc_AccountTest extends TestCase
|
|||
$result=$this->object->find_parent();
|
||||
$this->assertEquals($result,700);
|
||||
}
|
||||
public function dataFormatAccount()
|
||||
public static function dataFormatAccount()
|
||||
{
|
||||
return array(
|
||||
['60élépànç%','60ELEPANC'],
|
||||
|
|
@ -253,6 +253,7 @@ class Acc_AccountTest extends TestCase
|
|||
* @param string $p_result
|
||||
* @dataProvider dataFormatAccount
|
||||
*/
|
||||
#[DataProvider('dataFormatAccount')]
|
||||
public function testFormatAccount($param,$p_result)
|
||||
{
|
||||
global $g_connection;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
/**
|
||||
* Generated by PHPUnit_SkeletonGenerator on 2014-10-31 at 20:33:22.
|
||||
*
|
||||
|
|
@ -51,7 +51,7 @@ class Acc_Account_LedgerTest extends TestCase
|
|||
/**
|
||||
* @return array : idx [ $accounting,$from_date,$to_date,$nb_row,$tot_deb,$tot_cred]
|
||||
*/
|
||||
public function dataGet_row_date()
|
||||
public static function dataGet_row_date()
|
||||
{
|
||||
$array=array(
|
||||
['55000004','01.01.2019','31.12.2019',4,0,806.90]
|
||||
|
|
@ -66,6 +66,7 @@ class Acc_Account_LedgerTest extends TestCase
|
|||
* @covers Acc_Account_Ledger::get_row_date
|
||||
* @dataProvider dataGet_row_date
|
||||
*/
|
||||
#[DataProvider('dataGet_row_date')]
|
||||
public function testGetRowData($accounting,$from_date,$to_date,$nb_row,$tot_deb,$tot_cred)
|
||||
{
|
||||
global $g_connection;
|
||||
|
|
@ -289,7 +290,7 @@ class Acc_Account_LedgerTest extends TestCase
|
|||
$this->assertEquals($expected, $a_array);
|
||||
}
|
||||
|
||||
function dataGet_Name()
|
||||
static function dataGet_Name()
|
||||
{
|
||||
return array(
|
||||
array('10', 'Capital '),
|
||||
|
|
@ -301,6 +302,7 @@ class Acc_Account_LedgerTest extends TestCase
|
|||
* @covers Acc_Account_Ledger::get_name
|
||||
* @dataProvider dataGet_Name
|
||||
*/
|
||||
#[DataProvider('dataGet_Name')]
|
||||
public function testGet_name($id, $result)
|
||||
{
|
||||
$this->object->id=$id;
|
||||
|
|
@ -311,13 +313,14 @@ class Acc_Account_LedgerTest extends TestCase
|
|||
* @covers Acc_Account_Ledger::do_exist
|
||||
* @dataProvider dataDo_exist
|
||||
*/
|
||||
#[DataProvider('dataDo_exist')]
|
||||
public function testDo_exist($p_value, $result)
|
||||
{
|
||||
$this->object->id=$p_value;
|
||||
$this->assertEquals($this->object->do_exist(), $result);
|
||||
}
|
||||
|
||||
function dataDo_exist()
|
||||
static function dataDo_exist()
|
||||
{
|
||||
return array(
|
||||
array('400', 1),
|
||||
|
|
@ -380,7 +383,7 @@ class Acc_Account_LedgerTest extends TestCase
|
|||
$this->assertTrue(true, 'Ne peut être testé car vue HTML');
|
||||
}
|
||||
|
||||
public function dataGet_amount_side()
|
||||
public static function dataGet_amount_side()
|
||||
{
|
||||
return array(
|
||||
array(0, "="),
|
||||
|
|
@ -393,6 +396,7 @@ class Acc_Account_LedgerTest extends TestCase
|
|||
* @covers Acc_Account_Ledger::get_amount_side
|
||||
* @dataProvider dataGet_amount_side
|
||||
*/
|
||||
#[DataProvider('dataGet_amount_side')]
|
||||
public function testGet_amount_side($amount, $result)
|
||||
{
|
||||
$this->assertEquals($this->object->get_amount_side($amount), $result);
|
||||
|
|
@ -404,12 +408,13 @@ class Acc_Account_LedgerTest extends TestCase
|
|||
* @covers Acc_Account_Ledger::belong_ledger
|
||||
* @dataProvider DataBelong_ledger
|
||||
*/
|
||||
#[DataProvider('DataBelong_ledger')]
|
||||
public function testBelong_ledger($p_jrn, $result)
|
||||
{
|
||||
$this->assertEquals($this->object->belong_ledger($p_jrn), $result);
|
||||
}
|
||||
|
||||
function DataBelong_ledger()
|
||||
static function DataBelong_ledger()
|
||||
{
|
||||
return array(
|
||||
array(-1, 0),
|
||||
|
|
@ -420,7 +425,7 @@ class Acc_Account_LedgerTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
public function dataGet_account_ledger()
|
||||
public static function dataGet_account_ledger()
|
||||
{
|
||||
return array(
|
||||
array(0, array()),
|
||||
|
|
@ -435,6 +440,7 @@ class Acc_Account_LedgerTest extends TestCase
|
|||
* @covers Acc_Account_Ledger::get_account_ledger
|
||||
* @dataProvider dataGet_account_ledger
|
||||
*/
|
||||
#[DataProvider('dataGet_account_ledger')]
|
||||
public function testGet_account_ledger($p_jrn, $result)
|
||||
{
|
||||
$this->assertEquals($this->object->get_account_ledger($p_jrn), $result);
|
||||
|
|
@ -444,13 +450,14 @@ class Acc_Account_LedgerTest extends TestCase
|
|||
* @covers Acc_Account_Ledger::build_sql_account
|
||||
* @dataProvider DataBuild_Sql_account
|
||||
*/
|
||||
#[DataProvider('DataBuild_Sql_account')]
|
||||
public function testBuild_sql_account($p_jrn, $result)
|
||||
{
|
||||
$value=$this->object->build_sql_account($p_jrn);
|
||||
$this->assertEquals(trim($value), $result);
|
||||
}
|
||||
|
||||
public function DataBuild_Sql_account()
|
||||
public static function DataBuild_Sql_account()
|
||||
{
|
||||
return array(
|
||||
array(0, ""),
|
||||
|
|
@ -461,7 +468,7 @@ class Acc_Account_LedgerTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
function dataFind_Card()
|
||||
static function dataFind_Card()
|
||||
{
|
||||
return array(
|
||||
array('6191', '27'),
|
||||
|
|
@ -475,13 +482,14 @@ class Acc_Account_LedgerTest extends TestCase
|
|||
* @todo Implement testFind_card().
|
||||
* @dataProvider dataFind_Card()
|
||||
*/
|
||||
#[DataProvider('dataFind_Card')]
|
||||
public function testFind_card($p_value, $p_card)
|
||||
{
|
||||
$this->object->id=$p_value;
|
||||
$result=$this->object->find_card();
|
||||
$this->assertEquals($p_card, $result[0]['f_id']);
|
||||
}
|
||||
public function dataGet_used_accounting()
|
||||
public static function dataGet_used_accounting()
|
||||
{
|
||||
$array=array(
|
||||
["01.01.2020","31.12.2020",5,7,4]
|
||||
|
|
@ -500,6 +508,7 @@ class Acc_Account_LedgerTest extends TestCase
|
|||
* @covers Acc_Account_Ledger::get_used_accounting
|
||||
* @dataProvider dataGet_used_accounting
|
||||
*/
|
||||
#[DataProvider('dataGet_used_accounting')]
|
||||
public function testGet_UsedAcccounting($from_date,$to_date,$from_accounting,$to_accounting,$nb_accounting)
|
||||
{
|
||||
$a_result=Acc_Account_Ledger::get_used_accounting(from_date:$from_date
|
||||
|
|
@ -514,7 +523,7 @@ class Acc_Account_LedgerTest extends TestCase
|
|||
/**
|
||||
* @return array : idx [ $accounting,$from_date,$to_date,$nb_row,$tot_deb,$tot_cred]
|
||||
*/
|
||||
public function dataRowNotLettered()
|
||||
public static function dataRowNotLettered()
|
||||
{
|
||||
$array=array(
|
||||
['4400005','01.01.2019','31.12.2019',9,0,954.10]
|
||||
|
|
@ -527,6 +536,7 @@ class Acc_Account_LedgerTest extends TestCase
|
|||
* @covers Acc_Account_Ledger::get_row_date
|
||||
* @dataProvider dataRowNotLettered
|
||||
*/
|
||||
#[DataProvider('dataRowNotLettered')]
|
||||
public function testGetRowDataNotLetted($accounting,$from_date,$to_date,$nb_row,$tot_deb,$tot_cred)
|
||||
{
|
||||
global $g_connection;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
/**
|
||||
* Generated by PHPUnit_SkeletonGenerator on 2014-10-31 at 20:33:23.
|
||||
*/
|
||||
|
|
@ -29,7 +29,7 @@ class Acc_ComputeTest extends TestCase
|
|||
{
|
||||
|
||||
}
|
||||
public function dataGet_parameter()
|
||||
public static function dataGet_parameter()
|
||||
{
|
||||
return array( array('amount'),
|
||||
array('amount_vat'),
|
||||
|
|
@ -51,6 +51,7 @@ class Acc_ComputeTest extends TestCase
|
|||
* @todo Implement testGet_parameter().
|
||||
* @dataProvider dataGet_parameter
|
||||
*/
|
||||
#[DataProvider('dataGet_parameter')]
|
||||
public function testGet_parameter($data)
|
||||
{
|
||||
$result=$data;
|
||||
|
|
|
|||
|
|
@ -1,123 +0,0 @@
|
|||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
// Copyright (2002-2019) Author Dany De Bontridder <danydb@noalyss.eu>
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief concerne acc_ledger_history_purchaseTest.class
|
||||
*/
|
||||
class Acc_Ledger_History_PurchaseTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*/
|
||||
protected function setUp():void
|
||||
{
|
||||
include DIRTEST.'/global.php';
|
||||
global $g_connection;
|
||||
$this->object=new Acc_Ledger_History_Purchase($g_connection, [3], 92, 131, 'L');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
protected function tearDown():void
|
||||
{
|
||||
|
||||
}
|
||||
private function save_file($p_name,$content)
|
||||
{
|
||||
$hFile=fopen(__DIR__."/file/".$p_name,"w+");
|
||||
fwrite($hFile, $content);
|
||||
fclose($hFile);
|
||||
}
|
||||
//@covers Acc_Ledger_History_Financial::get_row , Acc_Ledger_History_Financial::get_data
|
||||
function testGet_Row()
|
||||
{
|
||||
$this->object->get_row();
|
||||
$this->assertEquals(16,count($this->object->get_data()),"Acc_Ledger_History_Purchase->get_data");
|
||||
|
||||
}
|
||||
//@covers Acc_Ledger_History_Financial::export_oneline_html
|
||||
function testExport_Oneline_Html()
|
||||
{
|
||||
//- Listing
|
||||
$name="acc_ledger_history_purchase_export_listing.html";
|
||||
$this->object->set_m_mode("L");
|
||||
ob_start();
|
||||
echo \Noalyss\Facility::page_start();
|
||||
$this->object->export_html();
|
||||
$content=ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->save_file($name, $content);
|
||||
$this->assertFileExists(__DIR__."/file/".$name);
|
||||
|
||||
//- Extended
|
||||
$name="acc_ledger_history_purchase_export_extended.html";
|
||||
$this->object->set_m_mode("E");
|
||||
ob_start();
|
||||
echo \Noalyss\Facility::page_start();
|
||||
$this->object->export_html();
|
||||
$content=ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->save_file($name, $content);
|
||||
$this->assertFileExists(__DIR__."/file/".$name);
|
||||
|
||||
//- Detail
|
||||
$name="acc_ledger_history_purchase_export_detail.html";
|
||||
$this->object->set_m_mode("D");
|
||||
ob_start();
|
||||
echo \Noalyss\Facility::page_start();
|
||||
$this->object->export_html();
|
||||
$content=ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->save_file($name, $content);
|
||||
$this->assertFileExists(__DIR__."/file/".$name);
|
||||
|
||||
//- Accounting
|
||||
$name="acc_ledger_history_purchase_export_accounting.html";
|
||||
$this->object->set_m_mode("D");
|
||||
ob_start();
|
||||
echo \Noalyss\Facility::page_start();
|
||||
$this->object->export_html();
|
||||
$content=ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->save_file($name, $content);
|
||||
$this->assertFileExists(__DIR__."/file/".$name);
|
||||
}
|
||||
/**
|
||||
* @covers Acc_Ledger_History::get_ledger_type
|
||||
*/
|
||||
|
||||
function testGet_Ledger_type()
|
||||
{
|
||||
$this->assertEquals($this->object->get_ledger_type(),'ACH');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
// Copyright (2002-2019) Author Dany De Bontridder <danydb@noalyss.eu>
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief concerne Acc_Ledger_History_SaleTest.class
|
||||
*/
|
||||
class Acc_Ledger_History_SaleTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*/
|
||||
protected function setUp():void
|
||||
{
|
||||
include 'global.php';
|
||||
global $g_connection;
|
||||
$this->object=new Acc_Ledger_History_Sale($g_connection,[2],92,131,'L');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
protected function tearDown():void
|
||||
{
|
||||
|
||||
}
|
||||
function testGet_row()
|
||||
{
|
||||
$this->object->get_row();
|
||||
$this->assertEquals(6,count($this->object->get_data()),"Acc_Ledger_History_Sale->get_row");
|
||||
}
|
||||
private function save_file($p_name,$content)
|
||||
{
|
||||
$hFile=fopen(__DIR__."/file/".$p_name,"w+");
|
||||
fwrite($hFile, $content);
|
||||
fclose($hFile);
|
||||
}
|
||||
//@covers Acc_Ledger_History_Sale::export_oneline_html
|
||||
function testExport_Oneline_Html()
|
||||
{
|
||||
//- Listing
|
||||
$name="acc_ledger_history_sale_export_listing.html";
|
||||
$this->object->set_m_mode("L");
|
||||
ob_start();
|
||||
echo \Noalyss\Facility::page_start();
|
||||
$this->object->export_html();
|
||||
$content=ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->save_file($name, $content);
|
||||
$this->assertFileExists(__DIR__."/file/".$name);
|
||||
|
||||
//- Extended
|
||||
$name="acc_ledger_history_sale_export_extended.html";
|
||||
$this->object->set_m_mode("E");
|
||||
ob_start();
|
||||
echo \Noalyss\Facility::page_start();
|
||||
$this->object->export_html();
|
||||
$content=ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->save_file($name, $content);
|
||||
$this->assertFileExists(__DIR__."/file/".$name);
|
||||
|
||||
//- Detail
|
||||
$name="acc_ledger_history_sale_export_detail.html";
|
||||
$this->object->set_m_mode("D");
|
||||
ob_start();
|
||||
echo \Noalyss\Facility::page_start();
|
||||
$this->object->export_html();
|
||||
$content=ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->save_file($name, $content);
|
||||
$this->assertFileExists(__DIR__."/file/".$name);
|
||||
|
||||
//- Accounting
|
||||
$name="acc_ledger_history_sale_export_accounting.html";
|
||||
$this->object->set_m_mode("D");
|
||||
ob_start();
|
||||
echo \Noalyss\Facility::page_start();
|
||||
$this->object->export_html();
|
||||
$content=ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->save_file($name, $content);
|
||||
$this->assertFileExists(__DIR__."/file/".$name);
|
||||
}
|
||||
/**
|
||||
* @covers Acc_Ledger_History::get_ledger_type
|
||||
*/
|
||||
|
||||
function testGet_Ledger_type()
|
||||
{
|
||||
$this->assertEquals($this->object->get_ledger_type(),'VEN');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
/**
|
||||
* @backupGlobals enabled
|
||||
* @coversDefaultClass Acc_Ledger_Purchase
|
||||
|
|
@ -431,7 +431,7 @@ class Acc_Ledger_PurchaseTest extends TestCase
|
|||
// check that all card has these attributes
|
||||
|
||||
}
|
||||
public function data_no_deductible()
|
||||
public static function data_no_deductible()
|
||||
{
|
||||
$aValue=array(
|
||||
[ ATTR_DEF_DEPENSE_NON_DEDUCTIBLE, 33.33 ,'qp_nd_amount',201.28,ATTR_DEF_ACCOUNT_ND_PERSO,'4890'],
|
||||
|
|
@ -454,6 +454,7 @@ class Acc_Ledger_PurchaseTest extends TestCase
|
|||
* @parameter $p_amount float the corresponding column in quant_purchase
|
||||
* @parameter $p_accounting string is the accounting counterpart for this not deductible fee($p_counterpart)
|
||||
*/
|
||||
#[DataProvider('data_no_deductible')]
|
||||
public function testInsertPurchase_No_Ded($p_attribut , $p_value,$p_column,$p_amount,$p_counterpart,$p_accounting)
|
||||
{
|
||||
global $g_connection;
|
||||
|
|
@ -507,6 +508,7 @@ class Acc_Ledger_PurchaseTest extends TestCase
|
|||
* @parameter $p_amount float the corresponding column in quant_purchase
|
||||
* @parameter $p_accounting string is the accounting counterpart for this not deductible fee($p_counterpart)
|
||||
*/
|
||||
#[DataProvider('data_no_deductible')]
|
||||
public function testInsertPurchase_No_Ded_reverse($p_attribut , $p_value,$p_column,$p_amount,$p_counterpart,$p_accounting)
|
||||
{
|
||||
global $g_connection;
|
||||
|
|
|
|||
|
|
@ -27,11 +27,13 @@
|
|||
* @brief
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
/**
|
||||
* @backupGlobals enabled
|
||||
*/
|
||||
require DIRTEST.'/global.php';
|
||||
|
||||
#[\AllowDynamicProperties]
|
||||
class Acc_LetterTest extends TestCase
|
||||
{
|
||||
/**
|
||||
|
|
@ -47,34 +49,27 @@ class Acc_LetterTest extends TestCase
|
|||
{
|
||||
include 'global.php';
|
||||
$this->a_column=array(
|
||||
"j_id",
|
||||
"j_date",
|
||||
"j_date_fmt",
|
||||
"jr_pj_number",
|
||||
"j_montant",
|
||||
"j_debit",
|
||||
"jr_comment",
|
||||
"jr_internal",
|
||||
"jr_id",
|
||||
"jr_def_id",
|
||||
"letter",
|
||||
"letter_diff",
|
||||
"currency_amount",
|
||||
"currency_id",
|
||||
"currency_rate",
|
||||
"currency_rate_ref",
|
||||
"cr_code_iso"
|
||||
);
|
||||
"j_id",
|
||||
"j_date",
|
||||
"j_date_fmt",
|
||||
"jr_pj_number",
|
||||
"j_montant",
|
||||
"j_debit",
|
||||
"jr_comment",
|
||||
"jr_internal",
|
||||
"jr_id",
|
||||
"jr_def_id",
|
||||
"letter",
|
||||
"letter_diff",
|
||||
"currency_amount",
|
||||
"currency_id",
|
||||
"currency_rate",
|
||||
"currency_rate_ref",
|
||||
"cr_code_iso"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test method is executed.
|
||||
*/
|
||||
protected function tearDown():void
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* the setUpBeforeClass():void template methods is called before the first test of the test case
|
||||
|
|
@ -86,15 +81,8 @@ class Acc_LetterTest extends TestCase
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDownAfterClass():void template methods is calleafter the last test of the test case class is run,
|
||||
*
|
||||
*/
|
||||
static function tearDownAfterClass():void
|
||||
{
|
||||
// include 'global.php';
|
||||
}
|
||||
public function dataget_Letter()
|
||||
|
||||
public static function dataget_Letter()
|
||||
{
|
||||
return array([22,577],[26,343]);
|
||||
}
|
||||
|
|
@ -104,6 +92,7 @@ class Acc_LetterTest extends TestCase
|
|||
* @covers Lettering_Card::get_letter
|
||||
* @dataProvider dataget_Letter
|
||||
*/
|
||||
#[DataProvider('dataget_Letter')]
|
||||
public function testget_letterAccount($p_fiche_id,$p_jrnx_id)
|
||||
{
|
||||
global $g_connection;
|
||||
|
|
@ -155,6 +144,7 @@ class Acc_LetterTest extends TestCase
|
|||
* @covers Lettering_Card::get_letter
|
||||
* @dataProvider dataget_Letter
|
||||
*/
|
||||
#[DataProvider('dataget_Letter')]
|
||||
public function testget_letterCard($p_fiche_id,$p_jrnx_id)
|
||||
{
|
||||
global $g_connection;
|
||||
|
|
@ -196,7 +186,7 @@ class Acc_LetterTest extends TestCase
|
|||
$g_connection->exec_sql("update jrnx set j_montant =$2 where j_id=$1 ",[$p_jrnx_id,$restore]);
|
||||
|
||||
}
|
||||
public function dataDateLimit()
|
||||
public static function dataDateLimit()
|
||||
{
|
||||
return array(
|
||||
[100,'01.01.2018','31.12.2018'],
|
||||
|
|
@ -210,6 +200,7 @@ class Acc_LetterTest extends TestCase
|
|||
* @param type $p_id
|
||||
* @dataProvider dataDateLimit
|
||||
*/
|
||||
#[DataProvider('dataDateLimit')]
|
||||
public function testDateLimitComputed($p_periode_id,$p_first_day,$p_last_day)
|
||||
{
|
||||
global $g_connection;
|
||||
|
|
@ -238,6 +229,7 @@ class Acc_LetterTest extends TestCase
|
|||
* @param type $p_id
|
||||
* @dataProvider dataDateLimit
|
||||
*/
|
||||
#[DataProvider('dataDateLimit')]
|
||||
public function testDateLimitGiven($p_periode_id,$p_first_day,$p_last_day)
|
||||
{
|
||||
global $g_connection;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
/**
|
||||
* Generated by PHPUnit_SkeletonGenerator on 2016-02-13 at 00:41:50.
|
||||
* @backupGlobals enabled
|
||||
|
|
@ -93,7 +94,7 @@ class Acc_OperationTest extends TestCase
|
|||
* provide data for testAmount_Currency
|
||||
* @return type
|
||||
*/
|
||||
public function data_amount_currency()
|
||||
public static function data_amount_currency()
|
||||
{
|
||||
return array(
|
||||
/* sale */
|
||||
|
|
@ -118,6 +119,7 @@ class Acc_OperationTest extends TestCase
|
|||
* @covers Acc_Operation::get_amount_currency
|
||||
* @dataProvider data_amount_currency
|
||||
*/
|
||||
#[DataProvider('data_amount_currency')]
|
||||
function testGet_AmountCurrency($p_jrn_id,$p_amount_currency)
|
||||
{
|
||||
global $g_connection;
|
||||
|
|
|
|||
|
|
@ -27,14 +27,14 @@
|
|||
* @brief
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
/**
|
||||
* @backupGlobals enabled
|
||||
* @coversDefaultClass \Acc_Payment
|
||||
*/
|
||||
require DIRTEST.'/global.php';
|
||||
|
||||
class AccPaymentTest extends TestCase
|
||||
class Acc_PaymentTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
@ -51,7 +51,7 @@ class AccPaymentTest extends TestCase
|
|||
include 'global.php';
|
||||
}
|
||||
|
||||
public function dataLoad()
|
||||
public static function dataLoad()
|
||||
{
|
||||
$a_json=array();
|
||||
$a_json[0]=['{
|
||||
|
|
@ -105,6 +105,7 @@ class AccPaymentTest extends TestCase
|
|||
* @param json $json
|
||||
* @covers ::load ::get_parameter
|
||||
*/
|
||||
#[DataProvider('dataLoad')]
|
||||
public function testLoad($json)
|
||||
{
|
||||
global $g_connection;
|
||||
|
|
@ -128,6 +129,7 @@ class AccPaymentTest extends TestCase
|
|||
* @param json $json
|
||||
* @covers ::from_array ::get_parameter
|
||||
*/
|
||||
#[DataProvider('dataLoad')]
|
||||
public function testFromArray($json)
|
||||
{
|
||||
global $g_connection;
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
* @brief Test Anc_Group
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
/**
|
||||
* @backupGlobals enabled
|
||||
* @coversDefaultClass \Anc_Group
|
||||
|
|
@ -82,7 +82,7 @@ class Anc_GroupTest extends TestCase
|
|||
$g_connection->exec_sql("delete from plan_analytique where pa_id>1");
|
||||
}
|
||||
|
||||
public function datasqlStmt()
|
||||
public static function datasqlStmt()
|
||||
{
|
||||
return array([1,"Group 1",1],
|
||||
[2,"Group 2",1],
|
||||
|
|
@ -98,6 +98,7 @@ class Anc_GroupTest extends TestCase
|
|||
* @param type $p_param
|
||||
* @covers
|
||||
*/
|
||||
#[DataProvider('datasqlStmt')]
|
||||
public function test_sqlStmt($p_ga_id,$pga_description,$ppa_id)
|
||||
{
|
||||
global $g_connection;
|
||||
|
|
@ -4,7 +4,7 @@ use PHPUnit\Framework\TestCase;
|
|||
/**
|
||||
* Generated by PHPUnit_SkeletonGenerator on 2014-11-08 at 14:23:52.
|
||||
*/
|
||||
class Anc_Key_Detail_SQLTest extends TestCase
|
||||
class Anc_Key_SQLTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
@ -289,4 +289,17 @@ class Card_PropertyTest extends TestCase
|
|||
$this->assertTrue(!empty($fiche->get_attribute(ATTR_DEF_ACCOUNT)),' accounting not computed');
|
||||
|
||||
}
|
||||
/**
|
||||
* @testdox test the function get_attribute
|
||||
*/
|
||||
public function testGet_attribute()
|
||||
{
|
||||
$g_connection=Dossier::connect();
|
||||
$fiche_goods = new \Fiche($g_connection);
|
||||
$fiche_goods->get_by_qcode("MARCHA");
|
||||
$id=$fiche_goods->id;
|
||||
|
||||
$this->assertTrue(\Card_Property::get_attribute($g_connection, $id, ATTR_DEF_QUICKCODE)=="MARCHA","Quick code not retrieved");
|
||||
$this->assertTrue(\Card_Property::get_attribute($g_connection, $id, -5)==false,"Inexistant property not detected");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
/**
|
||||
* Generated by PHPUnit_SkeletonGenerator on 2014-11-07 at 23:05:36.
|
||||
* @backupGlobals enabled
|
||||
|
|
@ -16,12 +16,7 @@ class FicheTest extends TestCase
|
|||
*/
|
||||
protected $object;
|
||||
private $g_connection;
|
||||
function __construct($name = null, array $data = [], $dataName = '')
|
||||
{
|
||||
|
||||
parent::__construct($name, $data, $dataName);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
|
|
@ -311,7 +306,7 @@ class FicheTest extends TestCase
|
|||
$this->assertEquals($nb_fiche, $nb_fiche_after, 'card not removed');
|
||||
}
|
||||
|
||||
public function dataEmptyQuickCode()
|
||||
public static function dataEmptyQuickCode()
|
||||
{
|
||||
return array(
|
||||
array("none", ""),
|
||||
|
|
@ -328,6 +323,7 @@ class FicheTest extends TestCase
|
|||
* @testdox testInsertEmptyQuickCode Test if it is possible to insert an empty quickcode
|
||||
* @dataProvider dataEmptyQuickCode
|
||||
*/
|
||||
#[DataProvider('dataEmptyQuickCode')]
|
||||
public function testInsertEmptyQuickCode($name, $quick_code)
|
||||
{
|
||||
//insert
|
||||
|
|
@ -338,7 +334,7 @@ class FicheTest extends TestCase
|
|||
$fiche->remove();
|
||||
|
||||
}
|
||||
function dataUpdateQuickCode()
|
||||
static function dataUpdateQuickCode()
|
||||
{
|
||||
return array(
|
||||
array('a+z+1-5', 'AZ1-5'),
|
||||
|
|
@ -358,6 +354,7 @@ class FicheTest extends TestCase
|
|||
* @testdox testUpdateEmptyQuickCode Test if it is possible to update an empty quickcode
|
||||
* @dataProvider dataUpdateQuickCode
|
||||
*/
|
||||
#[DataProvider('dataUpdateQuickCode')]
|
||||
public function testUpdateEmptyQuickCode($name, $quick_code)
|
||||
{
|
||||
$aCardId=[];
|
||||
|
|
@ -439,7 +436,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
function dataFormat_QuickCode()
|
||||
static function dataFormat_QuickCode()
|
||||
{
|
||||
return array(
|
||||
array('a+z+1-5','AZ1-5'),
|
||||
|
|
@ -458,12 +455,13 @@ where
|
|||
* @testdox test comptaproc.format_quickcode
|
||||
* @dataProvider dataFormat_Quickcode
|
||||
*/
|
||||
#[DataProvider('dataFormat_Quickcode')]
|
||||
public function testFormat_QuickCode($p_qcode,$p_result)
|
||||
{
|
||||
$this->assertEquals($p_result,$this->g_connection->get_value( "select comptaproc.format_quickcode($1)",
|
||||
[$p_result]),'quickcode is not transformed correctly');
|
||||
}
|
||||
function dataInsertName()
|
||||
static function dataInsertName()
|
||||
{
|
||||
return array(
|
||||
['',"Nom vide"],
|
||||
|
|
@ -475,6 +473,7 @@ where
|
|||
* @testdox Test if it is possible to insert an empty name
|
||||
* @dataProvider dataInsertName
|
||||
*/
|
||||
#[DataProvider('dataInsertName')]
|
||||
public function testInsertName($p_name,$p_result)
|
||||
{
|
||||
|
||||
|
|
@ -490,6 +489,7 @@ where
|
|||
* @testdox Test if it is possible to insert or update a empty name
|
||||
* @dataProvider dataInsertName
|
||||
*/
|
||||
#[DataProvider('dataInsertName')]
|
||||
public function testUpdateName($p_name,$p_result)
|
||||
{
|
||||
|
||||
|
|
@ -613,7 +613,7 @@ where
|
|||
$this->assertEquals($i,$fiche->get_attribute(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
}
|
||||
}
|
||||
public function dataAccount()
|
||||
public static function dataAccount()
|
||||
{
|
||||
return array(
|
||||
['600002','600002'],
|
||||
|
|
@ -626,6 +626,7 @@ where
|
|||
* @testdox testAccountInsert Set of the accounting while inserting, numeric with automatic
|
||||
* @dataProvider dataAccount
|
||||
*/
|
||||
#[DataProvider('dataAccount')]
|
||||
public function testAccountInsert($p_value,$p_expected)
|
||||
{
|
||||
$fiche=$this->build_fiche(2, 'PHPUNIT.ACCOUNT.INSERT');
|
||||
|
|
@ -697,6 +698,7 @@ where
|
|||
* @testdox testAccountUpdate et of the accounting while updating
|
||||
* @dataProvider dataAccount
|
||||
*/
|
||||
#[DataProvider('dataAccount')]
|
||||
public function testAccountUpdate($p_value,$p_expected)
|
||||
{
|
||||
$this->g_connection->exec_sql("update public.parameter set pr_value = $1 where pr_id=$2",
|
||||
|
|
@ -849,4 +851,6 @@ where
|
|||
|
||||
$this->g_connection->exec_sql ('update fiche set f_enable=$1 where f_id = $2 or f_id=$3',[1,34,35]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ use PHPUnit\Framework\TestCase;
|
|||
*/
|
||||
|
||||
#[\AllowDynamicProperties]
|
||||
class Follow_Up_DetailTest extends TestCase
|
||||
class FollowUp_DetailTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
|
|
@ -43,31 +43,22 @@ class ImpressTest extends TestCase
|
|||
{
|
||||
include 'global.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
protected function tearDown():void
|
||||
{
|
||||
|
||||
}
|
||||
private function setData()
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
include 'global.php';
|
||||
global $g_connection;
|
||||
$g_connection->exec_sql("delete from operation_analytique where oa_id > 48 and oa_id < 57");
|
||||
$sql="INSERT INTO operation_analytique
|
||||
$sql="INSERT INTO operation_analytique
|
||||
(oa_id,po_id,oa_amount,oa_description,oa_debit,j_id,oa_date,oa_row,oa_jrnx_id_source,oa_positive,f_id)
|
||||
VALUES
|
||||
(49,3,90.0000,'',true,18,'2018-02-24',0,NULL,'Y',NULL),
|
||||
(50,4,93.0000,'',true,18,'2018-02-24',1,NULL,'Y',NULL),
|
||||
(51,3,10.0000,'Déplacement',false,4,'2018-02-24',0,NULL,'Y',NULL),
|
||||
(52,1,30.0000,'Déplacement',false,4,'2018-02-24',1,NULL,'Y',NULL),
|
||||
(53,3,25.0000,'Vente de marchandises',false,7,'2018-02-24',0,NULL,'Y',NULL),
|
||||
(54,3,91.0000,'Eau',true,371,'2018-04-24',0,NULL,'Y',NULL),
|
||||
(55,3,80.0000,'Eau',true,371,'2018-04-24',1,NULL,'Y',NULL)";
|
||||
(49,3,90.0000,'',true,18,'2018-02-24',0,NULL,'Y',NULL),
|
||||
(50,4,93.0000,'',true,18,'2018-02-24',1,NULL,'Y',NULL),
|
||||
(51,3,10.0000,'Déplacement',false,4,'2018-02-24',0,NULL,'Y',NULL),
|
||||
(52,1,30.0000,'Déplacement',false,4,'2018-02-24',1,NULL,'Y',NULL),
|
||||
(53,3,25.0000,'Vente de marchandises',false,7,'2018-02-24',0,NULL,'Y',NULL),
|
||||
(54,3,91.0000,'Eau',true,371,'2018-04-24',0,NULL,'Y',NULL),
|
||||
(55,3,80.0000,'Eau',true,371,'2018-04-24',1,NULL,'Y',NULL)";
|
||||
$g_connection->exec_sql($sql);
|
||||
|
||||
}
|
||||
/**
|
||||
*
|
||||
|
|
@ -154,6 +145,7 @@ class ImpressTest extends TestCase
|
|||
* @covers Impress::parse_formula
|
||||
* @dataProvider getData_compute_amount
|
||||
*/
|
||||
#[DataProvider('getData_compute_amount')]
|
||||
function test_compute_amount($p_accounting,$p_amount)
|
||||
{
|
||||
global $g_connection;
|
||||
|
|
@ -224,7 +216,6 @@ class ImpressTest extends TestCase
|
|||
function test_parse_formula()
|
||||
{
|
||||
global $g_connection,$g_user;
|
||||
$this->setData();
|
||||
$a_formula=array(
|
||||
0=>array("sum 70% (credit is negative)", "[70%-s]",-456.80),
|
||||
1=>array("sum 70% (debit is negative)", "0-round([70%-s],2)",456.80),
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
* @brief
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
/**
|
||||
* @backupGlobals enabled
|
||||
*/
|
||||
|
|
@ -77,7 +77,7 @@ class PeriodeTest extends TestCase
|
|||
// include 'global.php';
|
||||
}
|
||||
|
||||
public function dataInsert()
|
||||
public static function dataInsert()
|
||||
{
|
||||
return array(
|
||||
[ '01.01.2023' , '31.01.2023','2020','2020.2023','NOK'],
|
||||
|
|
@ -95,6 +95,7 @@ class PeriodeTest extends TestCase
|
|||
* @param type $p_param
|
||||
* @covers
|
||||
*/
|
||||
#[DataProvider('dataInsert')]
|
||||
public function testInsert($p_start,$p_end,$p_exercice,$p_exercice_label,$p_status)
|
||||
{
|
||||
global $g_connection;
|
||||
|
|
@ -126,7 +127,7 @@ class PeriodeTest extends TestCase
|
|||
}
|
||||
$g_connection->exec_sql("delete from parm_periode where p_id > 144");
|
||||
}
|
||||
public function dataUpdate()
|
||||
public static function dataUpdate()
|
||||
{
|
||||
return array(
|
||||
[ '01.01.2023' , '31.01.2023','2023','2020.2023','OK'],
|
||||
|
|
@ -141,6 +142,7 @@ class PeriodeTest extends TestCase
|
|||
*
|
||||
*
|
||||
*/
|
||||
#[DataProvider('dataUpdate')]
|
||||
public function testUpdate($p_start,$p_end,$p_exercice,$p_exercice_label,$p_status)
|
||||
{
|
||||
|
||||
|
|
@ -183,7 +185,7 @@ class PeriodeTest extends TestCase
|
|||
}
|
||||
|
||||
|
||||
public function dataUpdateException()
|
||||
public static function dataUpdateException()
|
||||
{
|
||||
return array(
|
||||
[ '01.01.2023' , '31.01.2023','2020','2020.2023','NOK'],
|
||||
|
|
@ -199,6 +201,7 @@ class PeriodeTest extends TestCase
|
|||
*
|
||||
*
|
||||
*/
|
||||
#[DataProvider('dataUpdateException')]
|
||||
public function testUpdateException($p_start,$p_end,$p_exercice,$p_exercice_label,$p_status)
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class Ac_CommonTest extends TestCase
|
||||
{
|
||||
|
|
@ -207,7 +208,7 @@ class Ac_CommonTest extends TestCase
|
|||
/**
|
||||
* provides data to testIsDate
|
||||
*/
|
||||
function dataIsDate()
|
||||
static function dataIsDate():array
|
||||
{
|
||||
return array(
|
||||
['01.01.1992',1],
|
||||
|
|
@ -221,12 +222,13 @@ class Ac_CommonTest extends TestCase
|
|||
* @testdox isDate
|
||||
* @dataProvider dataIsDate
|
||||
*/
|
||||
function testIsDate($p_date,$expected)
|
||||
#[DataProvider('dataIsDate')]
|
||||
function testIsDate(string $p_date,int $expected)
|
||||
{
|
||||
$return=($expected==1)?$p_date:null;
|
||||
$this->assertEquals(isDate($p_date),$return,"Test $p_date");
|
||||
}
|
||||
function dataCompareDate ()
|
||||
static function dataCompareDate ():array
|
||||
{
|
||||
return array(
|
||||
['01.01.1992','05.02.2001',-1],
|
||||
|
|
@ -238,6 +240,7 @@ class Ac_CommonTest extends TestCase
|
|||
* @testDox test cmpDate
|
||||
* @dataProvider dataCompareDate
|
||||
*/
|
||||
#[DataProvider('dataCompareDate')]
|
||||
function testCompareDate($p_date,$p_date_2,$p_result)
|
||||
{
|
||||
$cmp=cmpDate($p_date,$p_date_2);
|
||||
|
|
@ -266,7 +269,7 @@ class Ac_CommonTest extends TestCase
|
|||
$this->assertEquals("<&",h("<&"));
|
||||
$this->assertEquals(0,h("0"));
|
||||
}
|
||||
function dataFormat_Date()
|
||||
static function dataFormat_Date()
|
||||
{
|
||||
return array(
|
||||
["01.05.2000","DD.MM.YYYY","DD.MM.YY",'01.05.00'],
|
||||
|
|
@ -287,6 +290,7 @@ class Ac_CommonTest extends TestCase
|
|||
* @throws Exception
|
||||
* @dataProvider dataFormat_date
|
||||
*/
|
||||
#[DataProvider('dataFormat_date')]
|
||||
function testFormatDate($p_date,$p_from,$p_to,$p_result)
|
||||
{
|
||||
$this->assertEquals($p_result,format_date($p_date,$p_from,$p_to));
|
||||
|
|
@ -305,7 +309,7 @@ class Ac_CommonTest extends TestCase
|
|||
$this->assertEquals("l''éléphant",Database::escape_string("l'éléphant"));
|
||||
$this->assertEquals("l\''éléphant",Database::escape_string("l\'éléphant"));
|
||||
}
|
||||
function dataNoalyss_trim()
|
||||
static function dataNoalyss_trim()
|
||||
{
|
||||
return array(["0","0"],
|
||||
[" 0 1 1 1 ","0 1 1 1"],
|
||||
|
|
@ -320,11 +324,12 @@ class Ac_CommonTest extends TestCase
|
|||
* @return void
|
||||
* @dataProvider dataNoalyss_trim
|
||||
*/
|
||||
#[DataProvider('dataNoalyss_trim')]
|
||||
function testNoalyss_trim($param,$result)
|
||||
{
|
||||
$this->assertEquals($result,noalyss_trim($param));
|
||||
}
|
||||
function dataNoalyss_replace() {
|
||||
static function dataNoalyss_replace() {
|
||||
return array(["0","/","0A0A","/A/A"],
|
||||
["A","*","0A0A","0*0*"],
|
||||
["0","/",null,""],
|
||||
|
|
@ -336,11 +341,12 @@ class Ac_CommonTest extends TestCase
|
|||
* @brief Comptability PHP 8.1 , null is not consider as an empty string
|
||||
* @dataProvider dataNoalyss_replace
|
||||
*/
|
||||
#[DataProvider('dataNoalyss_replace')]
|
||||
function testNoalyss_replace($search,$replace,$string,$expected)
|
||||
{
|
||||
$this->assertEquals($expected,noalyss_str_replace($search,$replace,$string));
|
||||
}
|
||||
function dataNoalyss_bcsub() {
|
||||
static function dataNoalyss_bcsub() {
|
||||
return array(
|
||||
[1,2,-1],
|
||||
[0,2,-2],
|
||||
|
|
@ -353,11 +359,12 @@ class Ac_CommonTest extends TestCase
|
|||
* @brief Comptability PHP 8.1 , null is not consider as an empty string
|
||||
* @dataProvider dataNoalyss_bcsub
|
||||
*/
|
||||
#[DataProvider('dataNoalyss_bcsub')]
|
||||
function testNoalyss_bcsub($numbera,$numberb,$expected)
|
||||
{
|
||||
$this->assertEquals($expected,noalyss_bcsub($numbera,$numberb));
|
||||
}
|
||||
function dataNoalyss_strip_tags() {
|
||||
static function dataNoalyss_strip_tags() {
|
||||
return array(
|
||||
[null,""],
|
||||
["",""],
|
||||
|
|
@ -370,6 +377,7 @@ class Ac_CommonTest extends TestCase
|
|||
* @brief Comptability PHP 8.1 , null is not consider as an empty string
|
||||
* @dataProvider dataNoalyss_strip_tags
|
||||
*/
|
||||
#[DataProvider('dataNoalyss_strip_tags')]
|
||||
function testNoalyss_strip_tags($string,$expected)
|
||||
{
|
||||
$this->assertEquals($expected,noalyss_strip_tags($string));
|
||||
|
|
@ -429,7 +437,7 @@ EOF;
|
|||
* supply data for user password
|
||||
* @return array[$password, $weakness] 0 means strong password
|
||||
*/
|
||||
public function dataCheck_password_strength()
|
||||
public static function dataCheck_password_strength()
|
||||
{
|
||||
return array(
|
||||
["AAAAAAA",5]
|
||||
|
|
@ -446,6 +454,7 @@ EOF;
|
|||
* @testDoc test the check_password_strength function
|
||||
* @dataProvider dataCheck_password_strength()
|
||||
*/
|
||||
#[DataProvider('dataCheck_password_strength')]
|
||||
public function testCheck_password_strength($p_password,$p_cnt)
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -123,6 +123,94 @@ class DatabaseCoreTest extends TestCase
|
|||
$this->assertStringContainsString("Documentation", $p_content,"$filename invalid content");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief read / write large object
|
||||
* @testDox read and write - unlink large object
|
||||
*
|
||||
*/
|
||||
public function testWrite_Read_large_object()
|
||||
{
|
||||
$md5="965765540c1531370e5856ff81696107";
|
||||
$file=__DIR__."/file/developpement-widget.pdf";
|
||||
// step 1 : we create the large object
|
||||
$binary_data= file_get_contents($file);
|
||||
$this->assertEquals($md5,md5($binary_data)," error when reading $file ");
|
||||
$oid = $this->object->lo_write($binary_data);
|
||||
$this->assertTrue ($oid != false , "writing in DB fails");
|
||||
// step 2 = read object
|
||||
$retrieve = $this->object->lo_read($oid);
|
||||
$this->assertEquals($md5,md5($retrieve)," error when retrieving file from db");
|
||||
|
||||
$target=$file."retrieve.pdf";
|
||||
if ( file_exists($target) ) { unlink($target);}
|
||||
|
||||
file_put_contents($target, $retrieve);
|
||||
$this->assertTrue(file_exists($target));
|
||||
|
||||
if ( file_exists($target) ) { unlink($target);}
|
||||
|
||||
$this->assertTrue( $this->object->lo_unlink($oid)," cannot unlink it");
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief import export large objects
|
||||
* @testDox import and export large object
|
||||
*
|
||||
*/
|
||||
public function testImport_export_large_object()
|
||||
{
|
||||
$md5="965765540c1531370e5856ff81696107";
|
||||
$file=__DIR__."/file/developpement-widget.pdf";
|
||||
$this->object->start();
|
||||
$oid = $this->object->lo_import($file);
|
||||
$this->object->commit();
|
||||
$this->assertTrue( $oid != false , "import of the file fails");
|
||||
$target=$file."-tmp";
|
||||
if ( file_exists($target) ) { unlink($target);}
|
||||
$this->object->start();
|
||||
$this->object->lo_export($oid , $file."-tmp");
|
||||
$this->object->commit();
|
||||
$this->assertTrue(file_exists($file."-tmp")," file not exported");
|
||||
if ( file_exists($target) ) { unlink($target);}
|
||||
$this->assertTrue( $this->object->lo_unlink($oid)," cannot unlink it");
|
||||
}
|
||||
|
||||
public function testReplace() {
|
||||
$string=<<<EOF
|
||||
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
|
||||
|
||||
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
|
||||
|
||||
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
|
||||
|
||||
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
|
||||
|
||||
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
|
||||
|
||||
EOF;
|
||||
$md5=md5($string);
|
||||
$this->object->start();
|
||||
$oid=$this->object->lo_write($string);
|
||||
$this->object->commit();
|
||||
|
||||
$this->object->start();
|
||||
$stringDB = $this->object->lo_read($oid);
|
||||
$this->object->commit();
|
||||
|
||||
$this->assertEquals(md5($string),md5($stringDB)," error string from DB corrupted");
|
||||
|
||||
$string = "second";
|
||||
$this->object->start();
|
||||
$this->object->lo_replace($string,$oid);
|
||||
$this->object->commit();
|
||||
|
||||
$this->object->start();
|
||||
$stringDB = $this->object->lo_read($oid);
|
||||
var_dump($stringDB);
|
||||
$this->object->commit();
|
||||
|
||||
$this->assertEquals(md5($string),md5($stringDB)," after lo_replace(), string from DB corrupted");
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue