PHPUNIT : adapt test

This commit is contained in:
sparkyx 2022-01-05 15:26:56 +01:00
parent 1d224ee165
commit c9e120b8f9
7 changed files with 27 additions and 20 deletions

View file

@ -4,6 +4,13 @@ Il faut configurer pour pouvoir l'utiliser :
2 . dans GLOBAL PATH (propriété du projet) ajouter le fichier phpunit.phar
3. Donner unit-test comme répertoire de test
Base de données
===============
Une base de données (dossier25.sql.gz) est donnée pour fonctionner avec les tests. Il faut la restaurer vide
puis exécuter le script avec psql
voir https://wiki.noalyss.eu/doku.php?id=tutoriaux:restaurer_un_dossier_manuellement
Paramètrage
===========

BIN
unit-test/dossier25.sql.gz Normal file

Binary file not shown.

View file

@ -313,7 +313,7 @@ class Acc_Account_LedgerTest extends TestCase
{
global $g_connection;
$accounting=new Acc_Account_Ledger($g_connection, '4511');
$this->assertEquals(319.05,$accounting->get_solde(),"get_solde");
$this->assertEquals(356.85,$accounting->get_solde(),"get_solde");
}
/**
@ -325,8 +325,8 @@ class Acc_Account_LedgerTest extends TestCase
$accounting=new Acc_Account_Ledger($g_connection, '4511');
$expected=array (
'debit' => '0',
'credit' => '319.0500',
'solde' => 319.05,
'credit' => '356.8500',
'solde' => 356.85,
);
$this->assertEquals($accounting->get_solde_detail(),$expected);
}

View file

@ -85,7 +85,7 @@ class Acc_LedgerTest extends TestCase
$this->object->id=2;
$sPj=$this->object->get_last_pj(2);
$this->assertEquals(39,$sPj);
$this->assertEquals(42,$sPj);
$this->object->id=0;
try {
@ -233,7 +233,7 @@ class Acc_LedgerTest extends TestCase
{
$this->object->id=2;
$r=$this->object->guess_pj();
$this->assertEquals("VEN40",$r);
$this->assertEquals("VEN43",$r);
}
/**
@ -293,8 +293,8 @@ class Acc_LedgerTest extends TestCase
$max=$g_connection->get_value("select max(p_id) from parm_periode");
$min=$g_connection->get_value("select min(p_id) from parm_periode");
$solde=$ledger->get_solde($min,$max);
$this->assertEquals($solde[1],4938.64);
$this->assertEquals($solde[0],4938.6400);
$this->assertEquals($solde[1],5156.4400);
$this->assertEquals($solde[0],5156.4400);
}

View file

@ -118,7 +118,7 @@ class Acc_Ledger_HistoryTest extends TestCase
$object=Acc_Ledger_History::factory($g_connection, [2],$p_min_id ,$p_max_id , "D", 'all');
$object->get_row();
$a_row=$object->get_data();
$this->assertEquals(13,count($a_row));
$this->assertEquals(16,count($a_row));
$object->set_filter_operation("paid");
$object->get_row();
@ -128,7 +128,7 @@ class Acc_Ledger_HistoryTest extends TestCase
$object->set_filter_operation("unpaid");
$object->get_row();
$a_row=$object->get_data();
$this->assertEquals(7,count($a_row));
$this->assertEquals(10,count($a_row));
}

View file

@ -134,7 +134,7 @@ EOF;
$anc_acc_list->card_poste=2;
$pdf_anc_acc=new PDF_Anc_Acc_List($anc_acc_list);
$pdf_anc_acc->export_pdf()->Output(__DIR__."/file/pdf_anc_acc_list-account-activity.pdf","F");
$this->assertEquals(77152,filesize(__DIR__."/file/pdf_anc_acc_list-account-activity.pdf"),
$this->assertEquals(77151,filesize(__DIR__."/file/pdf_anc_acc_list-account-activity.pdf"),
__DIR__."/file/pdf_anc_acc_list-account-activity.pdf incorrect ");
// By Activity / Card

View file

@ -54,7 +54,7 @@ class Print_Operation_CurrencyTest extends TestCase
$this->assertStringContainsString(" and jrnx.f_id in ( select f_id from fiche where fd_id=$4)",$sql);
$array=$object->get_data();
$this->assertEquals(count($array),0,"operation in EURO");
$this->assertEquals(count($array),5,"operation in EURO");
$object->setCurrency_id(1);
@ -82,12 +82,12 @@ class Print_Operation_CurrencyTest extends TestCase
$this->assertStringContainsString("where jrn.currency_id = $1 and",$sql);
$array=$object->get_data();
$this->assertEquals(0,count($array),"operation in EURO");
$this->assertEquals(18,count($array),"operation in EURO");
$object->setCurrency_id(1);
$array=$object->get_data();
$this->assertEquals(18,count($array),"operations in Dollars");
$this->assertEquals(20,count($array),"operations in Dollars");
}
/**
* @brief test Filter_Data_Currency_Card
@ -109,13 +109,13 @@ class Print_Operation_CurrencyTest extends TestCase
$this->assertStringContainsString("and f_id=$4",$sql);
$array=$object->get_data();
$this->assertEquals(0,count($array),"operation in EURO");
$this->assertEquals(4,count($array),"operation in EURO");
$object->setCurrency_id(1);
$object->setCard("FOURNI1");
$array=$object->get_data();
$this->assertEquals(2,count($array),"operations in Dollars");
$this->assertEquals(3,count($array),"operations in Dollars");
}
/**
* @brief test Filter_Data_Currency_Card_Accounting
@ -139,13 +139,13 @@ class Print_Operation_CurrencyTest extends TestCase
$sql=$object->SQL_Condition();
$this->assertStringContainsString("and j_poste >= $4 and j_poste <= $5",$sql);
$array=$object->get_data();
$this->assertEquals(0,count($array),"operation in EURO");
$this->assertEquals(9,count($array),"operation in EURO");
$object->setCurrency_id(1);
$array=$object->get_data();
$this->assertEquals(7,count($array),"operations in Dollars");
$this->assertEquals(8,count($array),"operations in Dollars");
}
function testPrint_operation_currency()
{
@ -170,7 +170,7 @@ class Print_Operation_CurrencyTest extends TestCase
Noalyss\Facility::save_file(__DIR__."/file", "print_operation_currency_by_accounting.csv",
$csv);
$this->assertEquals(0,count($array),"by_accounting operation in EURO");
$this->assertEquals(9,count($array),"by_accounting operation in EURO");
$_REQUEST['p_currency_code']=1;
$print_operation=Print_Operation_Currency::build("by_card");
@ -188,11 +188,11 @@ class Print_Operation_CurrencyTest extends TestCase
$this->assertEquals(2,count($array),"by_card operation in USD");
$this->assertEquals(3,count($array),"by_card operation in USD");
$print_operation=Print_Operation_Currency::build("all");
$array=$print_operation->getData_operation()->get_data();
$this->assertEquals(20,count($array),"all operations in Dollars");
$this->assertEquals(22,count($array),"all operations in Dollars");
ob_start();
$print_operation->export_csv($export);
$csv=ob_get_contents();