PRERELEASE 10A
This commit is contained in:
commit
83efa90a33
1141 changed files with 40635 additions and 85178 deletions
|
|
@ -110,9 +110,9 @@ class Ajax_MiscTest extends TestCase
|
|||
// card for Merchandise
|
||||
$fiche->set_fiche_def(1);
|
||||
Card_Property::load($fiche);
|
||||
$fiche->setAttribut(1, "Inserted by PHPUNIT-" . __CLASS__ . ":" . __FUNCTION__);
|
||||
$fiche->setAttribut(ATTR_DEF_TVA, '210A');
|
||||
$fiche->setAttribut(ATTR_DEF_QUICKCODE, 'MA1');
|
||||
$fiche->set_attribute(1, "Inserted by PHPUNIT-" . __CLASS__ . ":" . __FUNCTION__);
|
||||
$fiche->set_attribute(ATTR_DEF_TVA, '210A');
|
||||
$fiche->set_attribute(ATTR_DEF_QUICKCODE, 'MA1');
|
||||
$fiche->insert(1, $fiche->to_array());
|
||||
return $fiche;
|
||||
}
|
||||
|
|
|
|||
229
unit-test/include/class/Acc_DocumentTest.php
Normal file
229
unit-test/include/class/Acc_DocumentTest.php
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
<?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]
|
||||
);
|
||||
}
|
||||
static function get_variable() {
|
||||
$request = array(
|
||||
"ac" => "VEN",
|
||||
"gDossier" => 25,
|
||||
"ag_ref" => "FACTUR4-25",
|
||||
"dt_id" => 4,
|
||||
"e_client" => "CLIENT1",
|
||||
"ag_timestamp" => "19.06.2025",
|
||||
"ag_hour" => "",
|
||||
"ag_remind_date" => "",
|
||||
"ag_state" => 2,
|
||||
"ag_priority" => 2,
|
||||
"ag_dest" => 1,
|
||||
"operation" => "",
|
||||
"action" => "",
|
||||
"ag_title" => "Facture",
|
||||
"ag_description" => "",
|
||||
"nb_item" => 5,
|
||||
"e_march0" => "DOCUME",
|
||||
"e_march0_label" => "Documentation",
|
||||
"e_march0_price" => 121,
|
||||
"e_quant0" => 1,
|
||||
"e_march0_tva_id" => 6,
|
||||
"e_march0_tva_amount" => 0,
|
||||
"tvac_march0" => 121,
|
||||
"tva_march0" => 0,
|
||||
"htva_march0" => 121,
|
||||
"ad_id0" => 0,
|
||||
"e_march1" => "",
|
||||
"e_march1_label" => "",
|
||||
"e_march1_price" => "",
|
||||
"e_quant1" => 1,
|
||||
"e_march1_tva_id" => "",
|
||||
"e_march1_tva_amount" => 0,
|
||||
"tvac_march1" => 0,
|
||||
"tva_march1" => 0,
|
||||
"htva_march1" => 0,
|
||||
"ad_id1" => 0,
|
||||
"e_march2" => "",
|
||||
"e_march2_label" => "",
|
||||
"e_march2_price" => "",
|
||||
"e_quant2" => 1,
|
||||
"e_march2_tva_id" => "",
|
||||
"e_march2_tva_amount" => 0,
|
||||
"tvac_march2" => 0,
|
||||
"tva_march2" => 0,
|
||||
"htva_march2" => 0,
|
||||
"ad_id2" => 0,
|
||||
"e_march3" => "",
|
||||
"e_march3_label" => "",
|
||||
"e_march3_price" => "",
|
||||
"e_quant3" => 1,
|
||||
"e_march3_tva_id" => "",
|
||||
"e_march3_tva_amount" => 0,
|
||||
"tvac_march3" => 0,
|
||||
"tva_march3" => 0,
|
||||
"htva_march3" => 0,
|
||||
"ad_id3" => 0,
|
||||
"e_march4" => "",
|
||||
"e_march4_label" => "",
|
||||
"e_march4_price" => "",
|
||||
"e_quant4" => 1,
|
||||
"e_march4_tva_id" => "",
|
||||
"e_march4_tva_amount" => 0,
|
||||
"tvac_march4" => 0,
|
||||
"tva_march4" => 0,
|
||||
"htva_march4" => 0,
|
||||
"ad_id4" => 0,
|
||||
"6853eaa02e5af_ledger" => "O",
|
||||
"6853eaa02e5af" => 1,
|
||||
"d_id" => 0,
|
||||
"ag_id" => 3,
|
||||
"f_id_dest" => "",
|
||||
"sa" => "save_action_st2",
|
||||
"save_action_st2" => "Enregistrer",
|
||||
"e_ech"=>'',
|
||||
'p_currency_code'=>0,
|
||||
'p_currency_rate'=>1,
|
||||
'bon_comm'=>'N/A',
|
||||
'e_date'=>'14.08.2020'
|
||||
|
||||
);
|
||||
return $request;
|
||||
}
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
}
|
||||
/**
|
||||
* @testdox Test the standard invoice, check file
|
||||
* @covers Document::generate
|
||||
*/
|
||||
function testGenerateStandard()
|
||||
{
|
||||
$cn=Dossier::connect();
|
||||
$document=new \Acc_Document($cn);
|
||||
$document->md_id=INVOICE_STD;
|
||||
$document->d_id=160;
|
||||
$array=Acc_DocumentTest::get_variable();
|
||||
$array['e_pj']='phpunit';
|
||||
$ret=$document->generate($array);
|
||||
$this->assertStringContainsString("export.php",$ret,"Incorrect URL");
|
||||
$this->assertTrue($document->d_filename=='inv-std-phpunit.pdf'
|
||||
,'filename incorrect');
|
||||
$this->assertTrue($document->d_mimetype=="application/pdf"
|
||||
,"incorrect mimetype [{$document->d_mimetype}]");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ class Acc_ReconciliationTest extends TestCase {
|
|||
function testReconcilied() {
|
||||
$acc_reconciliation = $this->build_object();
|
||||
$array = $acc_reconciliation->get_data(0);
|
||||
$this->assertEquals(8, count($array), "count number of rows found");
|
||||
$this->assertEquals(6, count($array), "count number of rows found");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -100,6 +100,6 @@ class Acc_ReconciliationTest extends TestCase {
|
|||
$acc_reconciliation->build_temp_total_operation();
|
||||
$acc_reconciliation->build_temp_total_operation();
|
||||
$cnt = $this->connection->get_value("select count(*) from temp_total_operation");
|
||||
$this->assertEquals(16, $cnt, " incorrect number of rows");
|
||||
$this->assertEquals(12, $cnt, " incorrect number of rows");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
@ -109,15 +110,61 @@ class Acc_TVATest extends TestCase
|
|||
$vtva_rate->tva_sale="451";
|
||||
$vtva_rate->tva_both_side="0";
|
||||
$vtva_rate->tva_rate=0.21;
|
||||
|
||||
$vtva_rate->tva_peppol_code='S';
|
||||
$tva_rate_mtable=new Tva_Rate_MTable($vtva_rate);
|
||||
$tva_rate_mtable->setPreviousId(0);
|
||||
|
||||
$check = $tva_rate_mtable->check();
|
||||
|
||||
$this->assertTrue($result==$check," erreur pour $tva_code ");
|
||||
$this->display_error($tva_rate_mtable);
|
||||
if ( $result != $check)
|
||||
{
|
||||
print "Error for $peppopl_code\n";
|
||||
print_r($tva_rate_mtable->aerror);
|
||||
$this->display_error($tva_rate_mtable);
|
||||
}
|
||||
}
|
||||
function dataBuild() {
|
||||
static function dataCheckVatex() {
|
||||
return array(
|
||||
['S',true,null]
|
||||
,['Z',true,null]
|
||||
,['A',false,""]
|
||||
,['A',true,"XX"]
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @brief VATEX Mandatory of tva_peppol_code not in S or Z
|
||||
* @testdox VATEX Mandatory if tva_peppol_code not S or Z
|
||||
* @param type $tva_code
|
||||
* @param type $result
|
||||
*/
|
||||
#[DataProvider('dataCheckVatex')]
|
||||
function testCheckVatex($peppopl_code,$result,$vatex_code)
|
||||
{
|
||||
$cn=\Dossier::connect();
|
||||
$vtva_rate=new V_Tva_rate_SQL($cn,1);
|
||||
|
||||
$vtva_rate->tva_label="Test";
|
||||
$vtva_rate->tva_sale="451";
|
||||
$vtva_rate->tva_both_side="0";
|
||||
$vtva_rate->tva_rate=0.21;
|
||||
$vtva_rate->tva_peppol_code=$peppopl_code;
|
||||
$vtva_rate->vx_code=$vatex_code;
|
||||
$tva_rate_mtable=new Tva_Rate_MTable($vtva_rate);
|
||||
$tva_rate_mtable->setPreviousId(1);
|
||||
|
||||
$check = $tva_rate_mtable->check();
|
||||
|
||||
$this->assertTrue($result==$check," erreur pour $peppopl_code ");
|
||||
if ( $result != $check)
|
||||
{
|
||||
print "Error for $peppopl_code\n";
|
||||
print_r($tva_rate_mtable->aerror);
|
||||
$this->display_error($tva_rate_mtable);
|
||||
}
|
||||
}
|
||||
|
||||
static function dataBuild() {
|
||||
return array(
|
||||
['0A',4]
|
||||
,['0B',6]
|
||||
|
|
@ -133,6 +180,7 @@ class Acc_TVATest extends TestCase
|
|||
* @dataProvider dataBuild
|
||||
* @return void
|
||||
*/
|
||||
#[DataProvider('dataBuild')]
|
||||
function testBuild($tva_code,$result)
|
||||
{
|
||||
$cn=\Dossier::connect();
|
||||
|
|
|
|||
|
|
@ -137,10 +137,12 @@ class AccountRepositoryTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @testdox create a repository
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
function testCreate() {
|
||||
try {
|
||||
$repo = new \Database(0);
|
||||
$repo->exec_sql("drop database if exists phpunit_account_repository ");
|
||||
$repo->exec_sql("create database phpunit_account_repository encoding='utf8'");
|
||||
|
||||
$db = $this->make_conx();
|
||||
|
|
@ -160,7 +162,6 @@ class AccountRepositoryTest extends TestCase {
|
|||
$db->start();
|
||||
$nb_table = $db->get_value("select count(*) from information_schema.tables where table_schema='public'");
|
||||
$db->commit();
|
||||
$db->close();
|
||||
$this->assertEquals(11, $nb_table, " number of table incorrect $nb_table");
|
||||
} catch (\Exception $ex) {
|
||||
echo $ex->getMessage();
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@
|
|||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @backupGlobals enabled
|
||||
* @coversDefaultClass \Forecast
|
||||
* @backupGlobals disabled
|
||||
* @coversDefaultClass \Anticipation
|
||||
*/
|
||||
require DIRTEST.'/global.php';
|
||||
|
||||
class ForecastTest extends TestCase
|
||||
class AnticipationTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
@ -68,7 +68,7 @@ class ForecastTest extends TestCase
|
|||
{
|
||||
include 'global.php';
|
||||
global $g_connection;
|
||||
$g_connection->exec_sql('delete from forecast');
|
||||
$g_connection->exec_sql("delete from forecast");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -87,17 +87,15 @@ class ForecastTest extends TestCase
|
|||
* @testdox insert into forecast
|
||||
* @covers ::insert ::delete ::load
|
||||
*/
|
||||
public function testSQL_Insert()
|
||||
public function testSQL_Anticipation()
|
||||
{
|
||||
global $g_connection;
|
||||
$obj=new Forecast($g_connection);
|
||||
$obj->set_parameter("start_date", 111);
|
||||
$obj->set_parameter("end_date", 116);
|
||||
$obj->set_parameter("name","PhpUNIT 2014");
|
||||
$obj->insert();
|
||||
$this->assertTrue($obj->get_parameter("id")>0,"Cannot insert");
|
||||
$obj->delete();
|
||||
$this->assertFalse($obj->load(),"Cannot delete");
|
||||
$forecast_sql=new Forecast_SQL($g_connection);
|
||||
$forecast_sql->setp("f_name","phpunit");
|
||||
$forecast_sql->setp("f_start_date",92);
|
||||
$forecast_sql->setp("f_end_date",103);
|
||||
$forecast_sql->save();
|
||||
$this->assertEquals (1,$g_connection->get_value("select count(*) from forecast")," forecast not created");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -105,24 +103,20 @@ class ForecastTest extends TestCase
|
|||
* @testdox update into forecast
|
||||
* @covers ::insert ::delete ::load
|
||||
*/
|
||||
public function testSQL_Update()
|
||||
public function testClone()
|
||||
{
|
||||
global $g_connection;
|
||||
$obj=new Forecast($g_connection);
|
||||
$obj->set_parameter("start_date", 111);
|
||||
$obj->set_parameter("end_date", 116);
|
||||
$obj->set_parameter("name", "PhpUNIT 2014");
|
||||
$obj->insert();
|
||||
|
||||
$this->assertTrue($obj->get_parameter("id")>0,"Cannot insert");
|
||||
$obj->set_parameter('name','TEST UPDATE');
|
||||
$obj->save();
|
||||
$reload=new Forecast($g_connection,$obj->get_parameter("id"));
|
||||
$reload->load();
|
||||
$this->assertTrue($reload->get_parameter("name") == $obj->get_parameter("name"),"cannot update");
|
||||
$reload->delete();
|
||||
$this->assertFalse($reload->load(),"Cannot delete");
|
||||
global $g_connection;
|
||||
$forecast_sql=new Forecast_SQL($g_connection);
|
||||
$forecast_sql->setp("f_name","phpunit2");
|
||||
$forecast_sql->setp("f_start_date",92);
|
||||
$forecast_sql->setp("f_end_date",103);
|
||||
$forecast_sql->save();
|
||||
$id=$forecast_sql->getp('f_id');
|
||||
$anticipation = new \Anticipation($g_connection,$id);
|
||||
$clone_id = $anticipation->object_clone();
|
||||
$this->assertTrue(isNumber($clone_id)==1 && $clone_id > $id,"clone not created id = {$id} clone_id = {$clone_id}");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -27,6 +27,11 @@ use PHPUnit\Framework\TestCase;
|
|||
*/
|
||||
require DIRTEST . '/global.php';
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
/**
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class DocumentTest extends TestCase {
|
||||
|
||||
/**
|
||||
|
|
@ -147,21 +152,6 @@ 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();
|
||||
|
|
@ -195,13 +185,15 @@ class DocumentTest extends TestCase {
|
|||
$this->assertTrue($document->replace('CUST_NAME', $array) == 'Client 1', 'CUST_NAME');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @testdox Generate Document::generate(), Document::parseDocument(),Document::replace(); require unoconv -l in another session
|
||||
* @covers Document::generate(), Document::parseDocument(),Document::replace();
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
function testGenerate() {
|
||||
require_once 'global.php';
|
||||
require DIRTEST . '/global.php';
|
||||
|
||||
$cn = Dossier::connect();
|
||||
$md_id = $cn->get_value('select max(md_id) md_id from document_modele where md_name=$1', ['Balise']);
|
||||
$array['e_client'] = 'CLIENT';
|
||||
|
|
@ -217,23 +209,6 @@ class DocumentTest extends TestCase {
|
|||
$this->assertTrue($cnt_after == $cnt_before + 1, "One file generated");
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox test $_ENV['TMP']
|
||||
*/
|
||||
function testGenerateTmp() {
|
||||
$cn = Dossier::connect();
|
||||
$md_id = $cn->get_value('select max(md_id) md_id from document_modele where md_name=$1', ['Balise']);
|
||||
$array['e_client'] = 'CLIENT';
|
||||
$array['e_date'] = '21.03.2020';
|
||||
$document = new Document($cn, $md_id);
|
||||
$document->ag_id = 2;
|
||||
$document->md_id = $md_id;
|
||||
$cnt_before = $cn->get_value("select count(*) from document");
|
||||
$tEnv = $_ENV['TMP'];
|
||||
$_ENV['TMP'] = '/not.exist';
|
||||
$this->assertStringContainsString('échoué', $document->generate($array));
|
||||
$_ENV['TMP'] = $tEnv;
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox ExtractPdf export PDF tests Document::export_pdf, Document::transform2pdf()
|
||||
|
|
@ -262,10 +237,11 @@ 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],
|
||||
|
|
@ -281,6 +257,8 @@ class DocumentTest extends TestCase {
|
|||
* @backupGlobals enabled
|
||||
* @dataProvider dataReplace
|
||||
*/
|
||||
#[DataProvider('dataReplace')]
|
||||
|
||||
function testReplace2($tag_name, $value) {
|
||||
require "global.php";
|
||||
static $request = null;
|
||||
|
|
@ -299,7 +277,7 @@ class DocumentTest extends TestCase {
|
|||
$this->assertEquals($name, $value, $tag_name." fails");
|
||||
}
|
||||
|
||||
function dataBalance()
|
||||
static function dataBalance()
|
||||
{
|
||||
return array(
|
||||
['CLIENT1',27.29, 4204.14],
|
||||
|
|
@ -309,13 +287,13 @@ class DocumentTest extends TestCase {
|
|||
}
|
||||
/**
|
||||
* @testdox test balance
|
||||
* @backupGlobals enabled
|
||||
* @dataProvider dataBalance
|
||||
*/
|
||||
#[DataProvider('dataBalance')]
|
||||
function testBalance($quickcode,$balance_report,$balance_noreport)
|
||||
{
|
||||
require "global.php";
|
||||
require "global.php";
|
||||
global $g_parameter;
|
||||
static $request = null;
|
||||
static $parameter = null;
|
||||
$document = $this->build_document();
|
||||
|
|
@ -325,18 +303,19 @@ class DocumentTest extends TestCase {
|
|||
if ( $parameter == null ){
|
||||
$parameter=new \Noalyss_Parameter_Folder($document->db);
|
||||
}
|
||||
global $g_parameter;
|
||||
$g_parameter=$parameter;
|
||||
$g_parameter->MY_REPORT='Y';
|
||||
|
||||
$g_parameter->save('MY_REPORT');
|
||||
$request['qcode_dest']=$quickcode;
|
||||
|
||||
$this->assertEquals($document->replace('SOLDE',$request),$balance_report,"{$quickcode} balance_report fails");
|
||||
$g_parameter->MY_REPORT='N';
|
||||
$g_parameter->save('MY_REPORT');
|
||||
|
||||
$this->assertEquals($document->replace('SOLDE',$request),$balance_noreport,"{$quickcode} balance_noreport fails");
|
||||
|
||||
$g_parameter->MY_REPORT='Y';
|
||||
$g_parameter->save('MY_REPORT');
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
142
unit-test/include/class/FacturXTest.php
Normal file
142
unit-test/include/class/FacturXTest.php
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
<?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;
|
||||
|
||||
|
||||
/**
|
||||
* @testdox Class InvoiceUBL21 : used for managing invoice format UBL21
|
||||
* @backupGlobals false
|
||||
* @coversDefaultClass InvoiceUBL21Test
|
||||
*/
|
||||
class FacturXTest extends TestCase {
|
||||
|
||||
/**
|
||||
* @var Fiche
|
||||
*/
|
||||
protected $object;
|
||||
protected $connection;
|
||||
|
||||
/**
|
||||
* @testdox thx jr_id makes an $array
|
||||
* @covers \Noalyss\Invoice\XMLDocument\InvoiceUBL21::build_data
|
||||
*/
|
||||
function testBuild_Data() {
|
||||
$cn=\Dossier::connect();
|
||||
$facturx=new \Noalyss\XMLDocument\FacturX($cn);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @testdox Make an XML UBL21
|
||||
*/
|
||||
function testDOMMake_XML()
|
||||
{
|
||||
|
||||
$cn = \Dossier::connect();
|
||||
// clean data
|
||||
$cn->exec_sql('update jrn set jr_pj_name=null,jr_pj_type=null, jr_pj = null where jr_id=$1', [2]);
|
||||
|
||||
/**
|
||||
* create PDF Invoice
|
||||
*/
|
||||
$sold = new \Acc_Sold($cn, 2);
|
||||
$sold->get();
|
||||
$array = \Acc_Ledger_Sale::convert_to_array($sold);
|
||||
$array['gen_doc'] = -2; //<- Standard invoice
|
||||
$acc_document = new \Acc_Document($cn, 2);
|
||||
$acc_document->create_document($sold->det->jr_internal, $array);
|
||||
// verification du PDF dans DB
|
||||
$row = $cn->get_row("select jr_pj_name,jr_pj, jr_pj_type
|
||||
from jrn
|
||||
where jr_id=$1
|
||||
", [2]);
|
||||
|
||||
$this->assertTrue("inv-std-VEN2.pdf" == $row['jr_pj_name'], "Incorrect invoice name [{$row['jr_pj_name']}]");
|
||||
$this->assertTrue("application/pdf" == $row['jr_pj_type'], "Incorrect invoice type");
|
||||
$this->assertTrue($row['jr_pj'] != "", "OID not created");
|
||||
|
||||
/**
|
||||
* create invoice PDF
|
||||
*/
|
||||
$sold=new \Acc_Sold($cn,2);
|
||||
$sold->get();
|
||||
$array= \Acc_Ledger_Sale::convert_to_array($sold);
|
||||
$array['gen_doc']=-2; //<- Standard invoice
|
||||
$acc_document=new \Acc_Document($cn,2);
|
||||
$acc_document->create_document($sold->det->jr_internal, $array);
|
||||
// verification du PDF dans DB
|
||||
$row=$cn->get_row("select jr_pj_name,jr_pj, jr_pj_type
|
||||
from jrn
|
||||
where jr_id=$1
|
||||
",[2]);
|
||||
|
||||
$this->assertTrue("inv-std-VEN2.pdf"==$row['jr_pj_name'],"Incorrect invoice name [{$row['jr_pj_name']}]");
|
||||
$this->assertTrue("application/pdf"==$row['jr_pj_type'],"Incorrect invoice type");
|
||||
$this->assertTrue($row['jr_pj'] != "","OID not created");
|
||||
// get the file
|
||||
$cn->start();
|
||||
$pdf_filename= tempnam("/tmp", "phpunit");
|
||||
\Noalyss\Facility::save_file ('/tmp', __FUNCTION__.".txt", $pdf_filename);
|
||||
$acc_document->export_file($pdf_filename);
|
||||
$cn->commit();
|
||||
// make the facturX invoice
|
||||
$facturx = new \Noalyss\XMLDocument\FacturX($cn);
|
||||
$facturx->set_pdf_filename($pdf_filename);
|
||||
|
||||
$xml = $facturx->create_invoice(2);
|
||||
$oid=$cn->lo_write($xml);
|
||||
$this->assertTrue($oid != false , "cannot save XML in DB");
|
||||
$acc_document->replace_receipt($oid);
|
||||
$file= \Noalyss\Facility::save_file('/tmp', 'facturX', $xml);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief to verify : MY_COUNTRY_CODE, SIREN, SIRET
|
||||
*
|
||||
*/
|
||||
function testCompany_Data()
|
||||
{
|
||||
$cn=\Dossier::connect();
|
||||
$facturx=new \Noalyss\XMLDocument\FacturX($cn);
|
||||
$a_error=$facturx->check_company_data();
|
||||
$this->assertTrue(count($a_error)==10, "nb of error incorrect ".print_r($a_error,true));
|
||||
}
|
||||
|
||||
function testCustomer_Data()
|
||||
{
|
||||
$cn=\Dossier::connect();
|
||||
$facturx=new \Noalyss\XMLDocument\FacturX($cn);
|
||||
$facturx->build_data(2);
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ class Fiche_DefTest extends Testcase
|
|||
}
|
||||
|
||||
/**
|
||||
* @testdox getAttribut
|
||||
* @testdox load_attribute
|
||||
*/
|
||||
function testGetAttribut()
|
||||
{
|
||||
|
|
@ -168,7 +168,7 @@ class Fiche_DefTest extends Testcase
|
|||
$fiche_def=$this->getFicheDef();
|
||||
|
||||
$aProperty=$g_connection->get_array("select ad_id from jnt_fic_attr where fd_id=$1", [$fiche_def->id]);
|
||||
$this->assertEquals(count($fiche_def->getAttribut()),count($aProperty)," number of property different in db and function getAttribut");
|
||||
$this->assertEquals(count($fiche_def->load_attribute()),count($aProperty)," number of property different in db and function load_attribute");
|
||||
}
|
||||
/**
|
||||
* @testdox if we insert a attribut ; all the cards from this category will have these attributes
|
||||
|
|
|
|||
175
unit-test/include/class/InvoiceUBL21Test.php
Normal file
175
unit-test/include/class/InvoiceUBL21Test.php
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
<?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;
|
||||
|
||||
|
||||
/**
|
||||
* @testdox Class InvoiceUBL21 : used for managing invoice format UBL21
|
||||
* @backupGlobals false
|
||||
* @coversDefaultClass InvoiceUBL21Test
|
||||
*/
|
||||
class InvoiceUBL21Test extends TestCase {
|
||||
|
||||
/**
|
||||
* @var Fiche
|
||||
*/
|
||||
protected $object;
|
||||
protected $connection;
|
||||
|
||||
|
||||
/**
|
||||
* @testdox thx jr_id makes an $array
|
||||
* @covers \Noalyss\Invoice\XMLDocument\InvoiceUBL21::build_data
|
||||
*/
|
||||
function testBuild_Data() {
|
||||
$cn = \Dossier::connect();
|
||||
$ublinvoice21 = new \Noalyss\XMLDocument\InvoiceUBL21($cn);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief check that the parameter extra has a value or add a temporary one
|
||||
* @param $code (string) code to check
|
||||
* @param $value (string) temp value
|
||||
* @return true : operation succeed , false code doesn't exist
|
||||
*/
|
||||
function parameter_extra_set($code,$value)
|
||||
{
|
||||
$cn = \Dossier::connect();
|
||||
$c=$cn->get_value("select pe_value from parameter_extra where pe_code = $1",
|
||||
[$code]);
|
||||
$id=1;
|
||||
if ( $c == "") {
|
||||
$id = $cn->get_value(" update parameter_extra set pe_value=$1 where pe_code=$2 returning id",
|
||||
[$code,$value]);
|
||||
|
||||
}
|
||||
return ($id != "")?true:false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief if parameter extra has a temp value reset it to null
|
||||
* @param $code (string) code to check
|
||||
* @param $value (string) temp value
|
||||
* @return true : operation succeed , false code doesn't exist
|
||||
*/
|
||||
function parameter_extra_clean($code,$value)
|
||||
{
|
||||
$cn = \Dossier::connect();
|
||||
$c=$cn->get_value("select pe_value from parameter_extra where pe_code = $1",
|
||||
[$code]);
|
||||
$id=1;
|
||||
if ( $c == $value ) {
|
||||
$id = $cn->get_value(" update parameter_extra set pe_value=null where pe_code=$1 returning id",
|
||||
[$code]);
|
||||
|
||||
}
|
||||
return ($id != "")?true:false;
|
||||
}
|
||||
/**
|
||||
* @testdox Make an XML UBL21, create the PDF invoice and include it into the XML
|
||||
*/
|
||||
function testDOMMake_XML() {
|
||||
try {
|
||||
|
||||
$cn = \Dossier::connect();
|
||||
// clean first
|
||||
$cn->exec_sql('update jrn set jr_pj_name=null,jr_pj_type=null, jr_pj = null where jr_id=$1',[2]);
|
||||
$tmp_value= uniqid("phpunit");
|
||||
// COMPANY_BANK_IBAN and COMPANY_BANK_BIC must have a value
|
||||
|
||||
if ( ! $this->parameter_extra_set('COMPANY_BANK_IBAN',$tmp_value))
|
||||
{
|
||||
$this->assertTrue(false,"failed to set COMPANY_BANK_IBAN");
|
||||
}
|
||||
|
||||
if ( ! $this->parameter_extra_set('COMPANY_BANK_BIC',$tmp_value) )
|
||||
{
|
||||
$this->assertTrue(false,"failed to set COMPANY_BANK_IBAN");
|
||||
}
|
||||
|
||||
$cn->start();
|
||||
$ublinvoice21 = new \Noalyss\XMLDocument\InvoiceUBL21($cn);
|
||||
// create document
|
||||
$sold=new \Acc_Sold($cn,2);
|
||||
$sold->get();
|
||||
$array= \Acc_Ledger_Sale::convert_to_array($sold);
|
||||
$array['gen_doc']=-2; //<- Standard invoice
|
||||
$acc_document=new \Acc_Document($cn,2);
|
||||
$acc_document->create_document($sold->det->jr_internal, $array);
|
||||
$cn->commit();
|
||||
// verification du PDF dans DB
|
||||
$row=$cn->get_row("select jr_pj_name,jr_pj, jr_pj_type
|
||||
from jrn
|
||||
where jr_id=$1
|
||||
",[2]);
|
||||
|
||||
$this->assertTrue("inv-std-VEN2-pdf"==$row['jr_pj_name'],"Incorrect invoice name");
|
||||
$this->assertTrue("application/pdf"==$row['jr_pj_type'],"Incorrect invoice type");
|
||||
$this->assertTrue($row['jr_pj'] != "","OID not created");
|
||||
$cn->start();
|
||||
$pdf_filename= tempnam("/tmp", "phpunit");
|
||||
\Noalyss\Facility::save_file ('/tmp', __FUNCTION__.".txt", $pdf_filename);
|
||||
$acc_document->export_file($pdf_filename);
|
||||
$cn->commit();
|
||||
|
||||
|
||||
$ublinvoice21->set_pdf_filename($pdf_filename);
|
||||
$ublinvoice21->make_xml(2);
|
||||
$data_id = $ublinvoice21->get_data()['id'];
|
||||
$file = fopen("invoice-" . $data_id . ".xml", "w+");
|
||||
fwrite($file, $ublinvoice21->saveXML());
|
||||
fclose($file);
|
||||
$this->assertTrue(file_exists("invoice-" . $data_id . ".xml")
|
||||
,"file not create");
|
||||
echo "save saved invoice {$data_id}.xml \n";
|
||||
$this->parameter_extra_clean('COMPANY_BANK_IBAN',$tmp_value);
|
||||
$this->parameter_extra_clean('COMPANY_BANK_BIC',$tmp_value);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
echo "ERROR" ; ///$exc->getTraceAsString();
|
||||
}
|
||||
}
|
||||
|
||||
function testCompany_Data() {
|
||||
$cn = \Dossier::connect();
|
||||
$ublinvoice21 = new \Noalyss\XMLDocument\InvoiceUBL21($cn);
|
||||
$a_error=array();
|
||||
$a_error=$ublinvoice21->check_company_data();
|
||||
$this->assertTrue(count($a_error) ==8 , " nb of errors incorrect ".print_r($a_error,true));
|
||||
}
|
||||
|
||||
function testCustomer_Data() {
|
||||
$cn = \Dossier::connect();
|
||||
$ublinvoice21 = new \Noalyss\XMLDocument\InvoiceUBL21($cn);
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
|
@ -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.
|
||||
*
|
||||
|
|
@ -48,6 +48,37 @@ class Acc_Account_LedgerTest extends TestCase
|
|||
$this->assertEquals(count($array), 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array : idx [ $accounting,$from_date,$to_date,$nb_row,$tot_deb,$tot_cred]
|
||||
*/
|
||||
public static function dataGet_row_date()
|
||||
{
|
||||
$array=array(
|
||||
['55000004','01.01.2019','31.12.2019',4,0,806.90]
|
||||
,['55000005','01.01.2019','31.12.2019',3,3750.78,250.25]
|
||||
,['4400005','01.01.2019','31.12.2019',17,806.90,1761.00]
|
||||
,['4400005','01.03.2019','02.05.2019',9,602.19,848.80]
|
||||
);
|
||||
return $array;
|
||||
}
|
||||
/**
|
||||
* @brief test function Acc_Account_Ledger::get_row_date
|
||||
* @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;
|
||||
$g_connection->clear_all_prepare();
|
||||
$acc_account_ledger=new Acc_Account_Ledger( $g_connection, $accounting);
|
||||
$acc_account_ledger->get_row_date($from_date,$to_date);
|
||||
$nb_actual_row=count($acc_account_ledger->row);
|
||||
$this->assertEquals($nb_row,$nb_actual_row,"error received $nb_row rows");
|
||||
$this->assertEquals($tot_deb,$acc_account_ledger->tot_deb,"error amount incorrect received ".$acc_account_ledger->tot_deb);
|
||||
$this->assertEquals($tot_cred,$acc_account_ledger->tot_cred,"error amount incorrect received ".$acc_account_ledger->tot_cred);
|
||||
|
||||
}
|
||||
/**
|
||||
* @covers Acc_Account_Ledger::get_row_date
|
||||
*/
|
||||
|
|
@ -259,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 '),
|
||||
|
|
@ -271,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;
|
||||
|
|
@ -281,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),
|
||||
|
|
@ -350,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, "="),
|
||||
|
|
@ -363,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);
|
||||
|
|
@ -374,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),
|
||||
|
|
@ -390,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()),
|
||||
|
|
@ -405,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);
|
||||
|
|
@ -414,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, ""),
|
||||
|
|
@ -431,7 +468,7 @@ class Acc_Account_LedgerTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
function dataFind_Card()
|
||||
static function dataFind_Card()
|
||||
{
|
||||
return array(
|
||||
array('6191', '27'),
|
||||
|
|
@ -445,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]
|
||||
|
|
@ -470,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
|
||||
|
|
@ -480,5 +519,34 @@ class Acc_Account_LedgerTest extends TestCase
|
|||
$this->assertEquals($nb_accounting,count($a_result)
|
||||
,"number of accounting incorrect for (\$from_date,\$to_date,\$from_accounting,\$to_accounting,\$nb_accounting : ($from_date,$to_date,$from_accounting,$to_accounting,$nb_accounting");
|
||||
|
||||
}
|
||||
/**
|
||||
* @return array : idx [ $accounting,$from_date,$to_date,$nb_row,$tot_deb,$tot_cred]
|
||||
*/
|
||||
public static function dataRowNotLettered()
|
||||
{
|
||||
$array=array(
|
||||
['4400005','01.01.2019','31.12.2019',9,0,954.10]
|
||||
,['4400005','01.03.2019','02.05.2019',3,0,246.61]
|
||||
);
|
||||
return $array;
|
||||
}
|
||||
/**
|
||||
* @brief test function Acc_Account_Ledger::get_row_date only unlettered
|
||||
* @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;
|
||||
$g_connection->clear_all_prepare();
|
||||
$acc_account_ledger=new Acc_Account_Ledger( $g_connection, $accounting);
|
||||
$acc_account_ledger->get_row_date(p_from:$from_date,p_to:$to_date,let:2);
|
||||
$nb_actual_row=count($acc_account_ledger->row);
|
||||
$this->assertEquals($nb_row,$nb_actual_row,"error received $nb_row rows");
|
||||
$this->assertEquals($tot_deb,$acc_account_ledger->tot_deb,"error amount incorrect received ".$acc_account_ledger->tot_deb);
|
||||
$this->assertEquals($tot_cred,$acc_account_ledger->tot_cred,"error amount incorrect received ".$acc_account_ledger->tot_cred);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -194,7 +195,7 @@ class Acc_ComputeTest extends TestCase
|
|||
|
||||
public function testCompute()
|
||||
{
|
||||
print "**********************************************";
|
||||
print "**********************************************";
|
||||
print PHP_EOL;
|
||||
print "<h1> OUTPUT IN HTML , USE LYNX TO READ</h1>";
|
||||
print PHP_EOL;
|
||||
|
|
@ -223,7 +224,7 @@ class Acc_ComputeTest extends TestCase
|
|||
catch (Exception $exc)
|
||||
{
|
||||
echo $exc->getMessage();
|
||||
error_log($exc->getTraceAsString());
|
||||
record_log($exc->getTraceAsString());
|
||||
$this->assertTrue(FALSE);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -578,7 +578,7 @@ class Acc_LedgerTest extends TestCase
|
|||
{
|
||||
global $g_connection;
|
||||
$ledger=new Acc_Ledger($g_connection,4);
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectException(\Exception::class);
|
||||
$array=[
|
||||
"p_jrn"=>"15",
|
||||
"p_jrn_deb_max_line"=>5,
|
||||
|
|
@ -598,7 +598,7 @@ class Acc_LedgerTest extends TestCase
|
|||
{
|
||||
global $g_connection;
|
||||
$ledger=new Acc_Ledger($g_connection,4);
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectException(\Exception::class);
|
||||
$array=[
|
||||
"p_jrn"=>"15",
|
||||
"p_jrn_deb_max_line"=>5,
|
||||
|
|
@ -901,7 +901,9 @@ class Acc_LedgerTest extends TestCase
|
|||
ob_end_clean();
|
||||
\Noalyss\Facility::save_file(__DIR__."/file", "acc_ledger-input_new.html", $result);
|
||||
$size=filesize(__DIR__."/file/acc_ledger-input_new.html");
|
||||
$this->assertTrue($size == 16044 ," output input_new is not what it is expected");
|
||||
$expected=15985;
|
||||
$delta =$size-$expected;
|
||||
$this->assertTrue($delta == 0 ," output input_new is $size expected $expected not what it is expected DELTA=$delta, file to check ".__DIR__."/file/acc_ledger-input_new.html");
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,13 +1,14 @@
|
|||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
/**
|
||||
* @backupGlobals enabled
|
||||
* @coversDefaultClass Acc_Ledger_Purchase
|
||||
* @covers Fiche
|
||||
*
|
||||
*/
|
||||
#[\AllowDynamicProperties]
|
||||
class Acc_Ledger_PurchaseTest extends TestCase
|
||||
{
|
||||
|
||||
|
|
@ -167,6 +168,10 @@ class Acc_Ledger_PurchaseTest extends TestCase
|
|||
$fiche_def=new Fiche_Def($g_connection,5);
|
||||
// prepare test , clean
|
||||
$fiche_def->RemoveAttribut([20,21,22,50,51,52,53,31]);
|
||||
$g_connection->exec_sql("delete from jrnx where j_poste=$1",
|
||||
['4119999']);
|
||||
$g_connection->exec_sql("delete from tmp_pcmn where pcm_val=$1",
|
||||
['4119999']);
|
||||
}
|
||||
/**
|
||||
* @covers Acc_Ledger_Purchase::verify
|
||||
|
|
@ -430,7 +435,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'],
|
||||
|
|
@ -453,6 +458,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;
|
||||
|
|
@ -461,8 +467,8 @@ class Acc_Ledger_PurchaseTest extends TestCase
|
|||
//-- modify card 29 : ELECTR
|
||||
$fiche=new Fiche($g_connection,29);
|
||||
$fiche->set_f_enable("1");
|
||||
$fiche->setAttribut($p_attribut,$p_value);
|
||||
$fiche->setAttribut($p_counterpart,$p_accounting);
|
||||
$fiche->set_attribute($p_attribut,$p_value);
|
||||
$fiche->set_attribute($p_counterpart,$p_accounting);
|
||||
$a_attribut=$fiche->to_array();
|
||||
$this->assertEquals($a_attribut['av_text'.$p_attribut],$p_value,"Attribut $p_attribut not set to $p_value%");
|
||||
|
||||
|
|
@ -506,6 +512,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;
|
||||
|
|
@ -516,8 +523,8 @@ class Acc_Ledger_PurchaseTest extends TestCase
|
|||
//-- modify card 29 : ELECTR
|
||||
$fiche=new Fiche($g_connection,29);
|
||||
$fiche->set_f_enable("1");
|
||||
$fiche->setAttribut($p_attribut,$p_value);
|
||||
$fiche->setAttribut($p_counterpart,$p_accounting);
|
||||
$fiche->set_attribute($p_attribut,$p_value);
|
||||
$fiche->set_attribute($p_counterpart,$p_accounting);
|
||||
$a_attribut=$fiche->to_array();
|
||||
$this->assertEquals($a_attribut['av_text'.$p_attribut],$p_value,"Attribut $p_attribut not set to $p_value%");
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use PHPUnit\Framework\TestCase;
|
|||
* @backupGlobals enabled
|
||||
* @coversDefaultClass Acc_Ledger_Sale
|
||||
*/
|
||||
#[\AllowDynamicProperties]
|
||||
class Acc_Ledger_SaleTest extends TestCase
|
||||
{
|
||||
|
||||
|
|
@ -143,7 +144,7 @@ class Acc_Ledger_SaleTest extends TestCase
|
|||
$g_connection->exec_sql("alter sequence s_jrn_pj2 restart with 40");
|
||||
// set TVA_RATE by default
|
||||
$g_connection->exec_sql("update tva_rate set tva_poste='41142,45142' where tva_id=5");
|
||||
$g_connection->exec_sql("update tva_rate set tva_reverse_account=null where tva_id=5");
|
||||
$g_connection->exec_sql("update tva_rate d set tva_reverse_account=null where tva_id=5");
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -155,7 +156,15 @@ class Acc_Ledger_SaleTest extends TestCase
|
|||
$this->object->verify_operation($this->array);
|
||||
$this->assertTrue(TRUE);
|
||||
}
|
||||
|
||||
static function tearDownAfterClass():void
|
||||
{
|
||||
|
||||
global $g_connection;
|
||||
$g_connection->exec_sql("delete from jrnx where j_poste=$1",
|
||||
['4119999']);
|
||||
$g_connection->exec_sql("delete from tmp_pcmn where pcm_val=$1",
|
||||
['4119999']);
|
||||
}
|
||||
/**
|
||||
* @covers Acc_Ledger_Sale::insert
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -89,7 +89,9 @@ class Acc_Ledger_searchTest extends TestCase
|
|||
$r=$ledger->display_search_form();
|
||||
\Noalyss\Facility::save_file(__DIR__."/file", "acc_ledger_search-test_display_search_form.html", $r);
|
||||
$filesize=strlen($r);
|
||||
$this->assertTrue($filesize==10966,"Size of the html string for display_search_form see "
|
||||
$expected=10971;
|
||||
$delta =$filesize-$expected;
|
||||
$this->assertTrue($delta == 0,"Size of the html string for display_search_form see delta = $delta , size=$filesize, expected=$expected "
|
||||
. __DIR__."/file/acc_ledger_search-test_display_search_form.html ");
|
||||
}
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -27,19 +27,20 @@
|
|||
* @brief
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
/**
|
||||
* @backupGlobals enabled
|
||||
*/
|
||||
require DIRTEST.'/global.php';
|
||||
|
||||
class Acc_Letter extends TestCase
|
||||
#[\AllowDynamicProperties]
|
||||
class Acc_LetterTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Fiche
|
||||
*/
|
||||
protected $object;
|
||||
private $a_column;
|
||||
private $a_column;
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test method is executed.
|
||||
|
|
@ -48,34 +49,27 @@ class Acc_Letter 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
|
||||
|
|
@ -87,15 +81,8 @@ class Acc_Letter 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]);
|
||||
}
|
||||
|
|
@ -105,12 +92,13 @@ class Acc_Letter 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;
|
||||
$letter = new Lettering_Account($g_connection);
|
||||
$fiche=new Fiche($g_connection,$p_fiche_id);
|
||||
$letter->set_parameter('account', $fiche->strAttribut(ATTR_DEF_ACCOUNT));
|
||||
$letter->set_parameter('account', $fiche->get_attribute(ATTR_DEF_ACCOUNT));
|
||||
$letter->set_parameter('start', '01.01.2010' );
|
||||
$letter->set_parameter('end', '31.12.2019');
|
||||
|
||||
|
|
@ -156,12 +144,13 @@ class Acc_Letter 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;
|
||||
$letter = new Lettering_Card($g_connection);
|
||||
$fiche=new Fiche($g_connection,$p_fiche_id);
|
||||
$letter->set_parameter('quick_code', $fiche->strAttribut(ATTR_DEF_QUICKCODE));
|
||||
$letter->set_parameter('quick_code', $fiche->get_attribute(ATTR_DEF_QUICKCODE));
|
||||
$letter->set_parameter('start', '01.01.2010' );
|
||||
$letter->set_parameter('end', '31.12.2019');
|
||||
|
||||
|
|
@ -197,7 +186,7 @@ class Acc_Letter 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'],
|
||||
|
|
@ -211,6 +200,7 @@ class Acc_Letter 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;
|
||||
|
|
@ -239,6 +229,7 @@ class Acc_Letter 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,9 +1,11 @@
|
|||
<?php
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
/**
|
||||
* Generated by PHPUnit_SkeletonGenerator on 2016-02-13 at 00:41:50.
|
||||
* @backupGlobals enabled
|
||||
*/
|
||||
#[\AllowDynamicProperties]
|
||||
class Acc_OperationTest extends TestCase
|
||||
{
|
||||
/**
|
||||
|
|
@ -92,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 */
|
||||
|
|
@ -117,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;
|
||||
|
|
@ -319,7 +322,7 @@ class Acc_OperationTest extends TestCase
|
|||
// $this->assertEquals('BP19-1',$receipt,'Receipt number incorrect');
|
||||
$acc_operation=new Acc_Operation($g_connection);
|
||||
$acc_operation->set_id(250);
|
||||
$this->pj="";
|
||||
$acc_operation->pj="";
|
||||
$acc_operation->update_receipt();
|
||||
$new_receipt=$g_connection->get_value("select jr_pj_number from jrn where jr_id=250");
|
||||
$this->assertTrue($new_receipt== null,'receipt not set to null ');
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
@ -74,15 +74,15 @@ class Card_PropertyTest extends TestCase
|
|||
}
|
||||
$fiche=new Fiche($g_connection);
|
||||
$fiche->set_fiche_def($fiche_def->id);
|
||||
$fiche->attribut=$fiche_def->getAttribut();
|
||||
$fiche->attribut=$fiche_def->load_attribute();
|
||||
foreach ($fiche->attribut as $row)
|
||||
{
|
||||
$fiche->setAttribut($row->ad_id, "av_text = {$row->ad_id}");
|
||||
$fiche->set_attribute($row->ad_id, "av_text = {$row->ad_id}");
|
||||
}
|
||||
|
||||
$fiche->setAttribut(ATTR_DEF_QUICKCODE, self::FICHE_QCODE);
|
||||
$fiche->setAttribut(ATTR_DEF_ACCOUNT, '600');
|
||||
$fiche->setAttribut(ATTR_DEF_TVA, '');
|
||||
$fiche->set_attribute(ATTR_DEF_QUICKCODE, self::FICHE_QCODE);
|
||||
$fiche->set_attribute(ATTR_DEF_ACCOUNT, '600');
|
||||
$fiche->set_attribute(ATTR_DEF_TVA, '');
|
||||
$fiche->insert($fiche_def->id, $fiche->to_array());
|
||||
$fiche->load();
|
||||
}
|
||||
|
|
@ -147,15 +147,15 @@ class Card_PropertyTest extends TestCase
|
|||
$fiche=$this->getFiche();
|
||||
$fiche->load();
|
||||
$name="test ".microtime();
|
||||
$this->assertFalse($fiche->getAttribut(1)==$name, 'name not different');
|
||||
$fiche->setAttribut(1, $name);
|
||||
$this->assertFalse($fiche->load_attribute(1)==$name, 'name not different');
|
||||
$fiche->set_attribute(1, $name);
|
||||
$aProperty=$fiche->to_array();
|
||||
$this->assertEquals($name, $aProperty['av_text1'], 'name not identical in array');
|
||||
|
||||
Card_Property::update($fiche);
|
||||
|
||||
Card_Property::load($fiche);
|
||||
$this->assertEquals(trim($name), trim($fiche->strAttribut(1)), 'name identical in DB');
|
||||
$this->assertEquals(trim($name), trim($fiche->get_attribute(1)), 'name identical in DB');
|
||||
$this->assertEquals(trim($name), trim($fiche->getName()), 'name identical in DB');
|
||||
}
|
||||
|
||||
|
|
@ -174,13 +174,13 @@ class Card_PropertyTest extends TestCase
|
|||
echo "fiche_def->id",$fiche_def->id;
|
||||
$fiche->set_fiche_def($fiche_def->id);
|
||||
|
||||
$fiche->setAttribut(ATTR_DEF_NAME,$name);
|
||||
$fiche->setAttribut(ATTR_DEF_ACCOUNT,$fiche_def->class_base.$name);
|
||||
$fiche->set_attribute(ATTR_DEF_NAME,$name);
|
||||
$fiche->set_attribute(ATTR_DEF_ACCOUNT,$fiche_def->class_base.$name);
|
||||
|
||||
$fiche->insert($fiche_def->id,$fiche->to_array());
|
||||
$this->assertEquals($name,$fiche->strAttribut(ATTR_DEF_NAME));
|
||||
$this->assertEquals($name,$fiche->get_attribute(ATTR_DEF_NAME));
|
||||
|
||||
$accounting=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
$accounting=$fiche->get_attribute(ATTR_DEF_ACCOUNT);
|
||||
$acc_accounting=new Acc_Account($g_connection,$accounting);
|
||||
|
||||
$this->assertEquals($acc_accounting->get_lib("pcm_lib"),$name,"Cannot create a new accouting with
|
||||
|
|
@ -206,7 +206,7 @@ class Card_PropertyTest extends TestCase
|
|||
global $g_connection;
|
||||
$fiche=$this->getFiche();
|
||||
Card_Property::load($fiche);
|
||||
$this->assertEquals(count($fiche->attribut), 36, 'there are not 36 attributes');
|
||||
$this->assertEquals(count($fiche->attribut), 41, 'there are not 41 attributes');
|
||||
$fiche=new Fiche($g_connection);
|
||||
Card_Property::load($fiche);
|
||||
$this->assertTrue(empty($fiche->attribut),'Card property must be equals to 0 (unknown category ');
|
||||
|
|
@ -279,14 +279,27 @@ class Card_PropertyTest extends TestCase
|
|||
$g_connection->exec_sql("update fiche_def set fd_create_account=true where fd_id=25");
|
||||
|
||||
$fiche=$this->getFiche();
|
||||
$fiche->setAttribut(ATTR_DEF_ACCOUNT, null);
|
||||
$fiche->set_attribute(ATTR_DEF_ACCOUNT, null);
|
||||
$aProperty=$fiche->to_array();
|
||||
Card_Property::update($fiche);
|
||||
$g_connection->commit();
|
||||
|
||||
$fiche->load();
|
||||
|
||||
$this->assertTrue(!empty($fiche->strAttribut(ATTR_DEF_ACCOUNT)),' accounting not computed');
|
||||
$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");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,8 +145,8 @@ class ContactTest extends TestCase
|
|||
$fiche=new Fiche($this->connection);
|
||||
$fiche->fiche_def=$this->object->fiche_def->id;
|
||||
$fiche->load();
|
||||
$fiche->setAttribut(ATTR_DEF_NAME, $param['name']);
|
||||
$fiche->setAttribut(ATTR_DEF_COMPANY, $param['company']);
|
||||
$fiche->set_attribute(ATTR_DEF_NAME, $param['name']);
|
||||
$fiche->set_attribute(ATTR_DEF_COMPANY, $param['company']);
|
||||
$fiche->insert($fiche->fiche_def,$fiche->to_array());
|
||||
$this->object->card_to_clean[]=$fiche->id;
|
||||
printf("Card to clean %s ",$fiche->id);
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -215,7 +210,7 @@ class FicheTest extends TestCase
|
|||
//-- modify card 29 : ELECTR
|
||||
$fiche = new Fiche($this->g_connection, 29);
|
||||
$fiche->set_f_enable("1");
|
||||
$fiche->setAttribut(20, "33.33");
|
||||
$fiche->set_attribute(20, "33.33");
|
||||
$a_attribut = $fiche->to_array();
|
||||
$this->assertEquals($a_attribut['av_text20'], 33.33, "Attribut 20 set to 33%");
|
||||
|
||||
|
|
@ -225,8 +220,8 @@ class FicheTest extends TestCase
|
|||
$this->g_connection->get_value("select ad_value from fiche_detail where f_id=$1 and ad_id=$2", [29, 20]),
|
||||
"Attribut ad_id 20 inserted");
|
||||
|
||||
$this->assertEquals("33.33", $fiche->strAttribut(20), "retrieve attribute 20");
|
||||
$fiche->setAttribut(20, "0.05");
|
||||
$this->assertEquals("33.33", $fiche->get_attribute(20), "retrieve attribute 20");
|
||||
$fiche->set_attribute(20, "0.05");
|
||||
Card_Property::update($fiche);
|
||||
$this->assertEquals("0.05",
|
||||
$this->g_connection->get_value("select ad_value from fiche_detail where f_id=$1 and ad_id=$2", [29, 20]),
|
||||
|
|
@ -256,12 +251,12 @@ class FicheTest extends TestCase
|
|||
$fiche_goods = new Fiche($this->g_connection);
|
||||
$fiche_goods->get_by_qcode("MARCHA");
|
||||
$this->assertEquals($fiche_goods->id, 23, "retrieve card by qcode");
|
||||
$this->assertEquals($fiche_goods->strAttribut(ATTR_DEF_NAME), "Marchandise1", "Retrieve name");
|
||||
$this->assertEquals($fiche_goods->get_attribute(ATTR_DEF_NAME), "Marchandise1", "Retrieve name");
|
||||
$this->assertEquals($fiche_goods->getName(), "Marchandise1", "Retrieve name from db");
|
||||
$fiche_2 = new Fiche($this->g_connection);
|
||||
$fiche_2->get_by_qcode("marcha ");
|
||||
$this->assertEquals($fiche_2->id, 23, "retrieve card by qcode");
|
||||
$this->assertEquals($fiche_2->strAttribut(ATTR_DEF_NAME), "Marchandise1", "Retrieve name");
|
||||
$this->assertEquals($fiche_2->get_attribute(ATTR_DEF_NAME), "Marchandise1", "Retrieve name");
|
||||
$this->assertEquals($fiche_2->getName(), "Marchandise1", "Retrieve name from db");
|
||||
}
|
||||
|
||||
|
|
@ -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,17 +323,18 @@ 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
|
||||
$fiche = new Fiche($this->g_connection);
|
||||
$fiche->insert(2, ['av_text13' => $quick_code, "av_text1" => $name]);
|
||||
$fiche->load();
|
||||
$this->assertTrue($fiche->id > 0 && !empty(trim($fiche->strAttribut(23))), 'error : card created with empty quickcode');
|
||||
$this->assertTrue($fiche->id > 0 && !empty(trim($fiche->get_attribute(23))), 'error : card created with empty quickcode');
|
||||
$fiche->remove();
|
||||
|
||||
}
|
||||
function dataUpdateQuickCode()
|
||||
static function dataUpdateQuickCode()
|
||||
{
|
||||
return array(
|
||||
array('a+z+1-5', 'AZ1-5'),
|
||||
|
|
@ -358,13 +354,14 @@ 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=[];
|
||||
//insert
|
||||
$fiche = new Fiche($this->g_connection);
|
||||
$fiche->insert(2, ['av_text23' => 'QC', "av_text1" => $name]);
|
||||
$this->assertTrue($fiche->id > 0 && !empty($fiche->strAttribut(23)), 'error : card created with empty quickcode');
|
||||
$this->assertTrue($fiche->id > 0 && !empty($fiche->get_attribute(23)), 'error : card created with empty quickcode');
|
||||
$aCardId[]=$fiche->get_id();
|
||||
|
||||
// add attributes of type card , and for another card, set it to this quickcode
|
||||
|
|
@ -401,19 +398,19 @@ where
|
|||
// ----
|
||||
$fiche_related1->load();
|
||||
$fiche_related2->load();
|
||||
$this->assertTrue($fiche_related1->id > 0 && !empty($fiche_related1->strAttribut(23)),'error related card
|
||||
$this->assertTrue($fiche_related1->id > 0 && !empty($fiche_related1->get_attribute(23)),'error related card
|
||||
not created properly');
|
||||
$this->assertTrue($fiche_related2->id > 0 && !empty($fiche_related2->strAttribut(23)),'error related card
|
||||
$this->assertTrue($fiche_related2->id > 0 && !empty($fiche_related2->get_attribute(23)),'error related card
|
||||
not created properly');
|
||||
// ----
|
||||
// check card attribute
|
||||
// ----
|
||||
foreach ($aAttribute as $nAttribute) {
|
||||
$this->assertEquals('QC',$fiche_related1->strAttribut($nAttribute['ad_id']),'Attribute QC is not set');
|
||||
$this->assertEquals('QC',$fiche_related2->strAttribut($nAttribute['ad_id']),'Attribute QC is not set');
|
||||
$this->assertEquals('QC',$fiche_related1->get_attribute($nAttribute['ad_id']),'Attribute QC is not set');
|
||||
$this->assertEquals('QC',$fiche_related2->get_attribute($nAttribute['ad_id']),'Attribute QC is not set');
|
||||
}
|
||||
|
||||
$fiche->setAttribut(23, $name);
|
||||
$fiche->set_attribute(23, $name);
|
||||
|
||||
|
||||
$fiche->update($fiche->to_array());
|
||||
|
|
@ -422,8 +419,8 @@ where
|
|||
|
||||
// check that the other attributes of type card have been updated
|
||||
foreach ($aAttribute as $nAttribute) {
|
||||
$this->assertEquals($fiche->get_quick_code(),$fiche_related1->strAttribut($nAttribute['ad_id']),'Attribute QC is not set');
|
||||
$this->assertEquals($fiche->get_quick_code(),$fiche_related2->strAttribut($nAttribute['ad_id']),'Attribute QC is not set');
|
||||
$this->assertEquals($fiche->get_quick_code(),$fiche_related1->get_attribute($nAttribute['ad_id']),'Attribute QC is not set');
|
||||
$this->assertEquals($fiche->get_quick_code(),$fiche_related2->get_attribute($nAttribute['ad_id']),'Attribute QC is not set');
|
||||
}
|
||||
|
||||
if ($fiche->is_used()) {
|
||||
|
|
@ -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)
|
||||
{
|
||||
|
||||
|
|
@ -482,7 +481,7 @@ where
|
|||
$fiche = new Fiche($this->g_connection);
|
||||
$fiche->insert(2, ['av_text23' => 'QC', "av_text1" => $p_name]);
|
||||
$fiche->load();
|
||||
$this->assertEquals($p_result,$fiche->strAttribut(ATTR_DEF_NAME),'incorrect name');
|
||||
$this->assertEquals($p_result,$fiche->get_attribute(ATTR_DEF_NAME),'incorrect name');
|
||||
$fiche->remove();
|
||||
|
||||
}
|
||||
|
|
@ -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)
|
||||
{
|
||||
|
||||
|
|
@ -497,7 +497,7 @@ where
|
|||
$fiche = new Fiche($this->g_connection);
|
||||
$fiche->insert(2, ['av_text23' => 'QC', "av_text1" => $p_name]);
|
||||
$fiche->load();
|
||||
$this->assertEquals($p_result,$fiche->strAttribut(ATTR_DEF_NAME),'incorrect name');
|
||||
$this->assertEquals($p_result,$fiche->get_attribute(ATTR_DEF_NAME),'incorrect name');
|
||||
$fiche->remove();
|
||||
}
|
||||
/**
|
||||
|
|
@ -507,14 +507,14 @@ where
|
|||
{
|
||||
$fiche=new Fiche($this->g_connection);
|
||||
$fiche->insert(2,array("av_text1"=>'Card for PHPUNIT','av_text23'=>'DUP'));
|
||||
$this->assertTrue($fiche->id > 0 && 'DUP'==$fiche->strAttribut(23),
|
||||
'error : card created with wrong quickcode'.$fiche->strAttribut(23));
|
||||
$this->assertTrue($fiche->id > 0 && 'DUP'==$fiche->get_attribute(23),
|
||||
'error : card created with wrong quickcode'.$fiche->get_attribute(23));
|
||||
for ($i=0;$i<100;$i++) {
|
||||
$fiche_duplicate = new Fiche($this->g_connection);
|
||||
$fiche_duplicate->insert(2, array("av_text1" => 'Base Card' . $i, 'av_text23' => 'DUP'));
|
||||
|
||||
$this->assertTrue($fiche_duplicate->id > $fiche->id && 'DUP' . $i == $fiche_duplicate->strAttribut(23),
|
||||
" error : card created with quickcode {$fiche_duplicate->strAttribut(23)} expected DUP{$i}");
|
||||
$this->assertTrue($fiche_duplicate->id > $fiche->id && 'DUP' . $i == $fiche_duplicate->get_attribute(23),
|
||||
" error : card created with quickcode {$fiche_duplicate->get_attribute(23)} expected DUP{$i}");
|
||||
|
||||
}
|
||||
$a_fiche_clean=$this->g_connection->get_array("select f_id from fiche where f_id >= $1",
|
||||
|
|
@ -542,8 +542,8 @@ where
|
|||
$fiche->remove();
|
||||
}
|
||||
$fiche->insert($p_category,array("av_text1"=>'Card for PHPUNIT','av_text23'=>$p_qcode));
|
||||
$this->assertTrue($fiche->id > 0 && $p_qcode==$fiche->strAttribut(23),
|
||||
'error : card created with wrong quickcode'.$fiche->strAttribut(23));
|
||||
$this->assertTrue($fiche->id > 0 && $p_qcode==$fiche->get_attribute(23),
|
||||
'error : card created with wrong quickcode'.$fiche->get_attribute(23));
|
||||
return $fiche;
|
||||
}
|
||||
/**
|
||||
|
|
@ -558,13 +558,13 @@ where
|
|||
$fiche_def->save_class_base('600');
|
||||
$fiche=$this->build_fiche(2,'TESTACCOUNT');
|
||||
// $start=$fiche->id;
|
||||
$this->assertEquals('6000001',$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
$this->assertEquals('6000001',$fiche->get_attribute(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
for ( $i=6000002; $i < 6000999;$i++) {
|
||||
$fiche->setAttribut(ATTR_DEF_ACCOUNT, "");
|
||||
$fiche->set_attribute(ATTR_DEF_ACCOUNT, "");
|
||||
Card_Property::update($fiche);
|
||||
$fiche->load();
|
||||
|
||||
$this->assertEquals($i,$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
$this->assertEquals($i,$fiche->get_attribute(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -581,13 +581,13 @@ where
|
|||
$fiche_def->save_class_base('620');
|
||||
$fiche=$this->build_fiche(2,'TESTACCOUNT');
|
||||
// $start=$fiche->id;
|
||||
$this->assertEquals('6200001',$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
$this->assertEquals('6200001',$fiche->get_attribute(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
for ( $i=6200002; $i < 6200999;$i++) {
|
||||
$fiche->setAttribut(ATTR_DEF_ACCOUNT, "");
|
||||
$fiche->set_attribute(ATTR_DEF_ACCOUNT, "");
|
||||
Card_Property::update($fiche);
|
||||
$fiche->load();
|
||||
|
||||
$this->assertEquals($i,$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
$this->assertEquals($i,$fiche->get_attribute(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -610,10 +610,10 @@ where
|
|||
$first=false;
|
||||
}
|
||||
$fiche->load();
|
||||
$this->assertEquals($i,$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
$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,12 +626,13 @@ 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');
|
||||
$fiche->setAttribut(ATTR_DEF_ACCOUNT, $p_value);
|
||||
$fiche->set_attribute(ATTR_DEF_ACCOUNT, $p_value);
|
||||
Card_Property::update($fiche);
|
||||
$this->assertEquals($p_expected,$fiche->strAttribut(ATTR_DEF_ACCOUNT)," cannot SET accounting");
|
||||
$this->assertEquals($p_expected,$fiche->get_attribute(ATTR_DEF_ACCOUNT)," cannot SET accounting");
|
||||
$this->assertTrue($this->g_connection->get_value("select count(*) from tmp_pcmn where pcm_val = $1",[$p_expected])==1
|
||||
," accounting not created in TMP_PCMN");
|
||||
$this->g_connection->exec_sql("delete from tmp_pcmn where pcm_val=$1",[$p_expected]);
|
||||
|
|
@ -650,19 +651,19 @@ where
|
|||
$fiche_def->set_autocreate(true);
|
||||
$fiche_def->save_class_base('600');
|
||||
$fiche=$this->build_fiche(2,'TESTACCOUNT');
|
||||
$fiche->setAttribut(ATTR_DEF_ACCOUNT, "");
|
||||
$fiche->set_attribute(ATTR_DEF_ACCOUNT, "");
|
||||
Card_Property::update($fiche);
|
||||
$fiche->load();
|
||||
$this->assertEquals('600CARDF1',$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
$this->assertEquals('600CARDF1',$fiche->get_attribute(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
|
||||
for ( $i=600002; $i < 600099;$i++) {
|
||||
$fiche->setAttribut(ATTR_DEF_NAME,'Card for testing '.$i);
|
||||
$fiche->setAttribut(ATTR_DEF_ACCOUNT, "");
|
||||
$fiche->set_attribute(ATTR_DEF_NAME,'Card for testing '.$i);
|
||||
$fiche->set_attribute(ATTR_DEF_ACCOUNT, "");
|
||||
Card_Property::update($fiche);
|
||||
$fiche->load();
|
||||
|
||||
$idx=$i-600000;
|
||||
$this->assertEquals("600CARDF".$idx,$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
$this->assertEquals("600CARDF".$idx,$fiche->get_attribute(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -687,7 +688,7 @@ where
|
|||
|
||||
$fiche->load();
|
||||
$expected="600".substr($i."PHPU",0,5);
|
||||
$this->assertEquals($expected,$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
$this->assertEquals($expected,$fiche->get_attribute(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -697,14 +698,15 @@ 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",
|
||||
array('N','MY_ALPHANUM'));
|
||||
$fiche=$this->build_fiche(2, 'PHPUNIT.ACCOUNT.UPDATE');
|
||||
$fiche->setAttribut(ATTR_DEF_ACCOUNT, $p_value);
|
||||
$fiche->set_attribute(ATTR_DEF_ACCOUNT, $p_value);
|
||||
$fiche->update($fiche->to_array());
|
||||
$this->assertEquals($p_expected,$fiche->strAttribut(ATTR_DEF_ACCOUNT)," cannot SET accounting");
|
||||
$this->assertEquals($p_expected,$fiche->get_attribute(ATTR_DEF_ACCOUNT)," cannot SET accounting");
|
||||
$this->assertTrue($this->g_connection->get_value("select count(*) from tmp_pcmn where pcm_val = $1",[$p_expected])==1
|
||||
," accounting not created in TMP_PCMN");
|
||||
$this->g_connection->exec_sql("delete from tmp_pcmn where pcm_val=$1",[$p_expected]);
|
||||
|
|
@ -722,12 +724,12 @@ where
|
|||
$fiche_def->set_autocreate(false);
|
||||
$fiche_def->save_class_base('600');
|
||||
$fiche=$this->build_fiche(2,'TESTACCOUNT');
|
||||
$this->assertEquals('600',$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
$this->assertEquals('600',$fiche->get_attribute(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
for ( $i=600003; $i < 600025;$i++) {
|
||||
$fiche->setAttribut(ATTR_DEF_ACCOUNT, "");
|
||||
$fiche->set_attribute(ATTR_DEF_ACCOUNT, "");
|
||||
Card_Property::update($fiche);
|
||||
$fiche->load();
|
||||
$this->assertEquals(600,$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
$this->assertEquals(600,$fiche->get_attribute(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
|
||||
}
|
||||
$fiche->remove();
|
||||
|
|
@ -746,7 +748,7 @@ where
|
|||
$fiche=new Fiche($this->g_connection);
|
||||
$fiche->insert(2,['av_text1'=>'PHPUNIT test Same accounting','av_text5'=>""]);
|
||||
$fiche->load();
|
||||
$this->assertEquals(600,$fiche->strAttribut(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
$this->assertEquals(600,$fiche->get_attribute(ATTR_DEF_ACCOUNT),'Account not properly created');
|
||||
$fiche->remove();
|
||||
}
|
||||
|
||||
|
|
@ -780,19 +782,19 @@ where
|
|||
$fiche=new Fiche($this->g_connection);
|
||||
$fiche->set_fiche_def(5);
|
||||
Card_Property::load($fiche);
|
||||
$fiche->setAttribut(1, "Inserted by PHPUNIT");
|
||||
$fiche->setAttribut(23, " a a a a");
|
||||
$fiche->set_attribute(1, "Inserted by PHPUNIT");
|
||||
$fiche->set_attribute(23, " a a a a");
|
||||
$fiche->insert("5", $fiche->to_array());
|
||||
$this->assertGreaterThan (0,$fiche->id, "Card no created");
|
||||
$fiche_target=new Fiche($this->g_connection,$fiche->id);
|
||||
$this->assertTrue("AAAA"==$fiche_target->strAttribut(23),"Insert Quick code format not correct");
|
||||
$fiche_target->setAttribut(ATTR_DEF_QUICKCODE, " a a a a a a ");
|
||||
$this->assertTrue("AAAA"==$fiche_target->get_attribute(23),"Insert Quick code format not correct");
|
||||
$fiche_target->set_attribute(ATTR_DEF_QUICKCODE, " a a a a a a ");
|
||||
$fiche_target->update($fiche_target->to_array());
|
||||
|
||||
// reload the card !!
|
||||
$fiche_target->load();
|
||||
|
||||
$this->assertTrue("AAAAAA"==$fiche_target->strAttribut(23),"Update Quick code format not correct");
|
||||
$this->assertTrue("AAAAAA"==$fiche_target->get_attribute(23),"Update Quick code format not correct");
|
||||
|
||||
$fiche->delete();
|
||||
}
|
||||
|
|
@ -820,14 +822,35 @@ where
|
|||
$fiche=$this->build_fiche(2,'TESTACCOUNT');
|
||||
|
||||
// Try to generate an account
|
||||
$fiche->setAttribut(ATTR_DEF_ACCOUNT, null);
|
||||
$fiche->set_attribute(ATTR_DEF_ACCOUNT, null);
|
||||
$fiche->load();
|
||||
|
||||
Card_Property::update($fiche);
|
||||
$fiche_updated=new Fiche($this->g_connection,$fiche->id);
|
||||
$fiche_updated->load();
|
||||
$this->assertEquals('6000001',$fiche_updated->strAttribut(ATTR_DEF_ACCOUNT),'account not computed properly');
|
||||
$this->assertEquals('6000001',$fiche_updated->get_attribute(ATTR_DEF_ACCOUNT),'account not computed properly');
|
||||
$this->g_connection->exec_sql('delete from tmp_pcmn where pcm_val=$1',['600TESTALPHA']);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox test Fiche::get_fiche_def
|
||||
* @covers Fiche::get_fiche_def
|
||||
* @return void
|
||||
*/
|
||||
public function testGetFicheDef()
|
||||
{
|
||||
$res=Fiche::get_fiche_def($this->g_connection, 5);
|
||||
$this->assertEquals(7,count($res),"number of all cards incorrect ");
|
||||
$this->g_connection->exec_sql ('update fiche set f_enable=$1 where f_id = $2 or f_id=$3',[0,34,35]);
|
||||
$res=Fiche::get_fiche_def($this->g_connection, 5);
|
||||
$this->assertEquals(7,count($res),"number of all cards incorrect ");
|
||||
$res=Fiche::get_fiche_def($this->g_connection, 5,inactive:0);
|
||||
$this->assertEquals(5,count($res),"number of all cards incorrect ");
|
||||
|
||||
|
||||
$this->g_connection->exec_sql ('update fiche set f_enable=$1 where f_id = $2 or f_id=$3',[1,34,35]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,8 +137,7 @@ class FollowupTest extends TestCase
|
|||
$content=ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertStringContainsString("BONDEC3-1", $content);
|
||||
$this->assertTrue(mb_strlen($content)==1621,"error result not valid $content size = ".mb_strlen($content));
|
||||
|
||||
$this->assertTrue(mb_strlen($content)>=1619 && mb_strlen($content)<1642,"error result not valid $content size = ".mb_strlen($content));
|
||||
|
||||
}
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -33,15 +33,15 @@ use PHPUnit\Framework\TestCase;
|
|||
* @coversDefaultClass \Follow_Up_Detail
|
||||
*/
|
||||
|
||||
|
||||
class Follow_Up_DetailTest extends TestCase
|
||||
#[\AllowDynamicProperties]
|
||||
class FollowUp_DetailTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Fiche
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
private $g_connection;
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test method is executed.
|
||||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class noalyssAppearanceTest extends TestCase
|
|||
$this->object->load();
|
||||
$this->assertEquals("#554433",$this->object->get_color("FOLDER"));
|
||||
$this->object->reset();
|
||||
$this->assertEquals("#ffffff",$this->object->get_color("FOLDER"));
|
||||
$this->assertEquals("#fafafa",$this->object->get_color("FOLDER"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ class Noalyss_Parameter_FolderTest extends TestCase
|
|||
"MY_TVA,".
|
||||
"MY_STREET,".
|
||||
"MY_NUMBER,".
|
||||
"MY_CP,".
|
||||
"MY_TEL,".
|
||||
"MY_PAYS,".
|
||||
"MY_COMMUNE,".
|
||||
"MY_POSTCODE,".
|
||||
"MY_PHONE,".
|
||||
"MY_COUNTRY,".
|
||||
"MY_CITY,".
|
||||
"MY_FAX,".
|
||||
"MY_ANALYTIC,".
|
||||
"MY_STRICT,".
|
||||
|
|
@ -67,7 +67,8 @@ class Noalyss_Parameter_FolderTest extends TestCase
|
|||
"MY_UPDLAB,".
|
||||
"MY_ANC_FILTER,".
|
||||
"MY_REPORT,".
|
||||
"MY_STOCK");
|
||||
"MY_STOCK,".
|
||||
"MY_COUNTRY_CODE");
|
||||
|
||||
}
|
||||
public function testNew()
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ use PHPUnit\Framework\TestCase;
|
|||
* @backupGlobals enabled
|
||||
*/
|
||||
require DIRTEST.'/global.php';
|
||||
|
||||
#[\AllowDynamicProperties]
|
||||
class PDF_Anc_Acc_ListTest extends TestCase
|
||||
{
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ EOF;
|
|||
$filesize=filesize(__DIR__."/file/pdf_anc_acc_list-card-activity.pdf");
|
||||
$this->assertTrue($filesize >= 77102 && $filesize <= 77289,
|
||||
__DIR__."/file/pdf_anc_acc_list-card-activity.pdf $filesize incorrect");
|
||||
|
||||
print __DIR__."/file/pdf_anc_acc_list-card-activity.pdf".PHP_EOL;
|
||||
// By Account / Activity
|
||||
$anc_acc_list=new Anc_Acc_List($g_connection);
|
||||
$anc_acc_list->to='31.12.2019';
|
||||
|
|
@ -137,6 +137,7 @@ EOF;
|
|||
$pdf_anc_acc->export_pdf()->Output(__DIR__."/file/pdf_anc_acc_list-account-activity.pdf","F");
|
||||
$this->assertGreaterThan(77149,filesize(__DIR__."/file/pdf_anc_acc_list-account-activity.pdf"),
|
||||
__DIR__."/file/pdf_anc_acc_list-account-activity.pdf incorrect ");
|
||||
print __DIR__."/file/pdf_anc_acc_list-account-activity.pdf".PHP_EOL;
|
||||
|
||||
// By Activity / Card
|
||||
$anc_acc_list=new Anc_Acc_List($g_connection);
|
||||
|
|
@ -148,6 +149,7 @@ EOF;
|
|||
$pdf_anc_acc->export_pdf()->Output(__DIR__."/file/pdf_anc_acc_list-activity-card.pdf","F");
|
||||
$this->assertGreaterThan(77600,filesize(__DIR__."/file/pdf_anc_acc_list-activity-card.pdf"),
|
||||
__DIR__."/file/pdf_anc_acc_list-activity-card.pdf incorrect");
|
||||
print __DIR__."/file/pdf_anc_acc_list-activity-card.pdf".PHP_EOL;
|
||||
|
||||
// By Activity / Account
|
||||
$anc_acc_list=new Anc_Acc_List($g_connection);
|
||||
|
|
@ -159,6 +161,7 @@ EOF;
|
|||
$pdf_anc_acc->export_pdf()->Output(__DIR__."/file/pdf_anc_acc_list-activity-account.pdf","F");
|
||||
$this->assertGreaterThan(76000,filesize(__DIR__."/file/pdf_anc_acc_list-activity-account.pdf"),
|
||||
__DIR__."/file/pdf_anc_acc_list-activity-account.pdf incorrect");
|
||||
print __DIR__."/file/pdf_anc_acc_list-activity-account.pdf".PHP_EOL;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
* @brief
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
/**
|
||||
* @backupGlobals enabled
|
||||
*/
|
||||
|
|
@ -77,17 +77,18 @@ 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'],
|
||||
[ '01.01.2023' , '31.01.2023','2023','2020.2023','OK'],
|
||||
[ '01.02.2023' , '28.02.2023','2020','2020.2023','NOK'],
|
||||
[ '01.02.2023' , '28.02.2023','2023','2020.2023','OK'],
|
||||
[ '01.02.2023' , '28.02.2023','2020','2020.2023','NOK'],
|
||||
[ '01.02.2023' , '28.01.2023','2023','2020.2023','NOK']
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief test the trigger comptaproc.check_periode()
|
||||
* @testdox insert - comptaproc.check_periode
|
||||
|
|
@ -95,10 +96,10 @@ 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;
|
||||
|
||||
$g_connection->exec_sql("delete from parm_periode where p_id > 144");
|
||||
$obj=new Parm_periode_SQL($g_connection);
|
||||
$obj->set('p_start',$p_start);
|
||||
|
|
@ -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)
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ use PHPUnit\Framework\TestCase;
|
|||
* @brief concerne print_LedgerTest
|
||||
* @coversDefaultClass Print_Ledger
|
||||
*/
|
||||
#[\AllowDynamicProperties]
|
||||
class print_LedgerTest extends TestCase
|
||||
{
|
||||
|
||||
|
|
@ -33,7 +34,7 @@ class print_LedgerTest extends TestCase
|
|||
* @var
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
private $from,$to;
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use PHPUnit\Framework\TestCase;
|
|||
* @coversDefaultClass Print_Ledger_Detail
|
||||
*/
|
||||
require DIRTEST.'/global.php';
|
||||
|
||||
#[\AllowDynamicProperties]
|
||||
class Print_Ledger_DetailTest extends TestCase
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ class print_ledger_simpleTest extends TestCase
|
|||
$ledger->export();
|
||||
$ledger->Output(__DIR__."/file/print_ledger_simple_purchase_paid.pdf", "F");
|
||||
$this->assertFileExists(__DIR__."/file/print_ledger_simple_purchase_paid.pdf");
|
||||
print __DIR__."/file/print_ledger_simple_purchase_paid.pdf".PHP_EOL;
|
||||
|
||||
// Unpaid
|
||||
//------------
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class Print_Ledger_Simple_Without_VatTest extends TestCase
|
|||
* @var
|
||||
*/
|
||||
protected $object;
|
||||
private $from,$to;
|
||||
private $from,$to;
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
|
|
|
|||
118
unit-test/include/lib/Single_RecordTest.php
Normal file
118
unit-test/include/lib/Single_RecordTest.php
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
* NOALYSS 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.
|
||||
*
|
||||
* NOALYSS 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 NOALYSS; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
// Copyright Author Dany De Bontridder danydb@aevalys.eu 22/10/23
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief test Single_Record
|
||||
*/
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class Single_RecordTest extends TestCase {
|
||||
|
||||
/**
|
||||
* @covers Single_Record::hidden
|
||||
* @covers Single_Record::__construct()
|
||||
* @global $g_connection
|
||||
*/
|
||||
function testHiddenDatabase() {
|
||||
global $g_connection;
|
||||
$test_dup = new \Single_Record("test_dup", $g_connection);
|
||||
$r = $test_dup->hidden();
|
||||
$this->assertTrue($test_dup->id > 0, " id not computed " . $test_dup);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Single_Record::hidden
|
||||
* @covers Single_Record::__construct()
|
||||
* @global $g_connection
|
||||
*/
|
||||
function testHiddenDefaultDatabase() {
|
||||
global $g_connection;
|
||||
global $cn;
|
||||
$cn = $g_connection;
|
||||
$test_dup = new \Single_Record("test_dup");
|
||||
$r = $test_dup->hidden();
|
||||
$this->assertTrue($test_dup->id > 0, " id not computed " . $test_dup);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Single_Record::hidden
|
||||
* @covers Single_Record::__construct()
|
||||
* @global $g_connection
|
||||
*/
|
||||
function testSequence() {
|
||||
global $g_connection;
|
||||
global $cn;
|
||||
$cn = $g_connection;
|
||||
$test_dup = new \Single_Record("test_dup");
|
||||
$r = $test_dup->hidden();
|
||||
$a = $test_dup->id;
|
||||
$this->assertTrue($test_dup->id > 0, " id not computed " . $test_dup);
|
||||
$r = $test_dup->hidden();
|
||||
$this->assertTrue($test_dup->id > $a, " id not incremented" . $test_dup);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Single_Record::save()
|
||||
* @global $g_connection
|
||||
*/
|
||||
function testSave() {
|
||||
global $g_connection;
|
||||
global $cn;
|
||||
$cn = $g_connection;
|
||||
$test_dup = new \Single_Record("test_dup");
|
||||
$r = $test_dup->hidden();
|
||||
$this->assertTrue($test_dup->id > 0, " id not computed " . $test_dup);
|
||||
$test_dup->save(["test_dup"=>$test_dup->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Single_Record::check()
|
||||
* @global $g_connection
|
||||
*/
|
||||
function testCheck() {
|
||||
global $g_connection;
|
||||
global $cn;
|
||||
$this->expectException (\Exception::class);
|
||||
$cn = $g_connection;
|
||||
$test_dup = new \Single_Record("test_dup");
|
||||
$r = $test_dup->hidden();
|
||||
$test_dup->save(["test_dup"=>$test_dup->id]);
|
||||
$this->assertTrue($test_dup->id > 0, " id not computed " . $test_dup);
|
||||
$test_dup->check(['test_dup'=>$test_dup->id]);
|
||||
$test_dup->check(['test_dup'=>$test_dup->id]);
|
||||
}
|
||||
/**
|
||||
* @covers Single_Record::get_count()
|
||||
* @global $g_connection
|
||||
*/
|
||||
function testCount() {
|
||||
global $g_connection;
|
||||
global $cn;
|
||||
$cn = $g_connection;
|
||||
$test_dup = new \Single_Record("test_dup");
|
||||
$r = $test_dup->hidden();
|
||||
$this->assertTrue($test_dup->id > 0, " id not computed " . $test_dup);
|
||||
$test_dup->save(["test_dup"=>$test_dup->id]);
|
||||
$cnt = $test_dup->get_count(['test_dup'=>$test_dup->id]);
|
||||
$this->assertTrue($cnt > 0,"not count") ;
|
||||
}
|
||||
}
|
||||
204
unit-test/include/lib/Table_Data_SQLTest.php
Normal file
204
unit-test/include/lib/Table_Data_SQLTest.php
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
<?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';
|
||||
|
||||
class FakeData1_SQL extends \Table_Data_SQL {
|
||||
|
||||
function __construct(Database $p_cn, $p_id = -1) {
|
||||
$this->table = "public.jrn";
|
||||
$this->primary_key = "jr_id";
|
||||
/*
|
||||
* List of columns
|
||||
*/
|
||||
$this->name = array(
|
||||
"jr_id" => "jr_id"
|
||||
, "jr_def_id" => "jr_def_id"
|
||||
, "jr_montant" => "jr_montant"
|
||||
, "jr_comment" => "jr_comment"
|
||||
, "jr_date" => "jr_date"
|
||||
, "jr_grpt_id" => "jr_grpt_id"
|
||||
, "jr_internal" => "jr_internal"
|
||||
, "jr_tech_date" => "jr_tech_date"
|
||||
, "jr_tech_per" => "jr_tech_per"
|
||||
, "jrn_ech" => "jrn_ech"
|
||||
, "jr_ech" => "jr_ech"
|
||||
, "jr_rapt" => "jr_rapt"
|
||||
, "jr_valid" => "jr_valid"
|
||||
, "jr_opid" => "jr_opid"
|
||||
, "jr_c_opid" => "jr_c_opid"
|
||||
, "jr_pj" => "jr_pj"
|
||||
, "jr_pj_name" => "jr_pj_name"
|
||||
, "jr_pj_type" => "jr_pj_type"
|
||||
, "jr_pj_number" => "jr_pj_number"
|
||||
, "jr_mt" => "jr_mt"
|
||||
, "jr_date_paid" => "jr_date_paid"
|
||||
, "jr_optype" => "jr_optype"
|
||||
, "currency_id" => "currency_id"
|
||||
, "currency_rate" => "currency_rate"
|
||||
, "currency_rate_ref" => "currency_rate_ref"
|
||||
);
|
||||
|
||||
/*
|
||||
* Type of columns
|
||||
*/
|
||||
$this->type = array(
|
||||
"jr_id" => "numeric"
|
||||
, "jr_def_id" => "numeric"
|
||||
, "jr_montant" => "numeric"
|
||||
, "jr_comment" => "text"
|
||||
, "jr_date" => "date"
|
||||
, "jr_grpt_id" => "numeric"
|
||||
, "jr_internal" => "text"
|
||||
, "jr_tech_date" => "date"
|
||||
, "jr_tech_per" => "numeric"
|
||||
, "jrn_ech" => "date"
|
||||
, "jr_ech" => "date"
|
||||
, "jr_rapt" => "text"
|
||||
, "jr_valid" => "boolean"
|
||||
, "jr_opid" => "numeric"
|
||||
, "jr_c_opid" => "numeric"
|
||||
, "jr_pj" => "oid"
|
||||
, "jr_pj_name" => "text"
|
||||
, "jr_pj_type" => "text"
|
||||
, "jr_pj_number" => "text"
|
||||
, "jr_mt" => "text"
|
||||
, "jr_date_paid" => "date"
|
||||
, "jr_optype" => "text"
|
||||
, "currency_id" => "numeric"
|
||||
, "currency_rate" => "numeric"
|
||||
, "currency_rate_ref" => "numeric"
|
||||
);
|
||||
|
||||
$this->default = array("jr_id" => "auto");
|
||||
|
||||
$this->date_format = "DD.MM.YYYY";
|
||||
parent::__construct($p_cn, $p_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox Test Table_Data_SQL
|
||||
* @coversDefaultClass
|
||||
* @global $g_connection
|
||||
*/
|
||||
class Table_Data_SQLTest extends TestCase {
|
||||
|
||||
/**
|
||||
* @testdox Load existing row
|
||||
* @covers load(), __construct
|
||||
|
||||
*/
|
||||
function testLoadExisting()
|
||||
{
|
||||
global $g_connection;
|
||||
$jrn=new FakeData1_SQL($g_connection,911);
|
||||
$this->assertTrue($jrn->jr_id==911," Load existing doesn't load 911");
|
||||
$this->assertTrue($jrn->jr_internal=='V000410'," jr_internal not correct");
|
||||
}
|
||||
/**
|
||||
* @testdox Not existing row
|
||||
* @covers load(), __construct
|
||||
*/
|
||||
function testLoadNotExists()
|
||||
{
|
||||
global $g_connection;
|
||||
$jrn=new FakeData1_SQL($g_connection,191911);
|
||||
$this->assertTrue($jrn->jr_id==-1," Load existing doesn't load 911");
|
||||
$this->assertTrue($jrn->jr_internal==null," jr_internal not correct");
|
||||
}
|
||||
/**
|
||||
* @testdox Virtual Column : formatted date
|
||||
* @covers load(), __construct ,set_virtual_col
|
||||
*/
|
||||
function testVirtualColFormattedDate()
|
||||
{
|
||||
global $g_connection;
|
||||
|
||||
$jrn=new FakeData1_SQL($g_connection);
|
||||
$jrn->jr_id=915;
|
||||
$jrn->set_virtual_col("str_date", " to_char(jr_tech_date,'DD.MM.YY HH24:MI:SS')");
|
||||
$jrn->load();
|
||||
$this->assertTrue($jrn->str_date=='05.01.22 13:01:46',"virtual col fails gets [{$jrn->str_date}]");
|
||||
}
|
||||
/**
|
||||
* @testdox Virtual Column : calc
|
||||
* @covers load(), __construct, set_virtual_col
|
||||
*/
|
||||
function testVirtualColCalc()
|
||||
{
|
||||
global $g_connection;
|
||||
$jrn=new FakeData1_SQL($g_connection);
|
||||
$jrn->jr_id=911;
|
||||
$jrn->set_virtual_col("double_amount", " jr_montant * 2 ");
|
||||
$jrn->load();
|
||||
$this->assertTrue($jrn->double_amount==2*$jrn->jr_montant,"virtual col fails gets [{$jrn->double_amount}]");
|
||||
}
|
||||
/**
|
||||
* @testdox Virtual Column : when case
|
||||
* @covers load(), __construct, set_virtual_col
|
||||
*/
|
||||
function testVirtualColWhenCase()
|
||||
{
|
||||
global $g_connection;
|
||||
$jrn=new FakeData1_SQL($g_connection);
|
||||
$jrn->set_virtual_col('day_date'," to_char(jr_date,'DD')");
|
||||
$jrn->set_virtual_col('day_event'," case when to_char(jr_date,'DD')::int % 2 = 0 then 'EVEN' else 'ODD' end ");
|
||||
$r=$jrn->seek();
|
||||
|
||||
$nb=\Database::num_row($r);
|
||||
$this->assertTrue ($nb > 0 , "nothing found");
|
||||
for ($x=0;$x < $nb ; $x++)
|
||||
{
|
||||
$a_jrn=\Database::fetch_array($r, $x);
|
||||
if ( $a_jrn['day_date'] % 2 == 0 ) $this->assertTrue( $a_jrn['day_event'] =='EVEN',"virtual col fails gets event ".var_export($a_jrn,true));
|
||||
if ( $a_jrn['day_date'] % 2 != 0 ) $this->assertTrue( $a_jrn['day_event']=='ODD',"virtual col fails gets event ".var_export($a_jrn,true));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @testdox Data_SQL::to_row and update :
|
||||
* @covers Data_SQL->to_row() and Table_Data_SQL->update()
|
||||
*/
|
||||
function testTo_Row()
|
||||
{
|
||||
global $g_connection;
|
||||
$jrn=new FakeData1_SQL($g_connection);
|
||||
$jrn->set_virtual_col("double_amount", " jr_montant * 2 ");
|
||||
$jrn->jr_id=911;
|
||||
$jrn->load();
|
||||
$this->assertTrue($jrn->jr_id==911," Load existing doesn't load 911");
|
||||
$this->assertTrue($jrn->jr_internal=='V000410'," jr_internal not correct");
|
||||
$this->assertTrue($jrn->double_amount==$jrn->jr_montant *2," virtual column double_amount not correct {$jrn->double_amount} and jr_montant is {$jrn->jr_montant}");
|
||||
$jrn->to_row(array("double_amount"=>-1));
|
||||
$this->assertTrue($jrn->double_amount==-1," virtual column double_amount not changed {$jrn->double_amount}");
|
||||
$this->assertTrue($jrn->jr_internal=='V000410'," jr_internal has changed");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
{
|
||||
|
||||
|
|
@ -465,5 +474,37 @@ EOF;
|
|||
,"error cannot generate strong password get $pass");
|
||||
}
|
||||
}
|
||||
|
||||
public static function dataCheck_Iban()
|
||||
{
|
||||
return array(
|
||||
['FR2617569000405121911339Y14', true]
|
||||
, ['FR8917569000504392936779O14', true]
|
||||
, ['FR7214508000702383844671J92', true]
|
||||
, ['FR26169000405121911339Y14', false]
|
||||
, ['FR89569000504392936779O14', false]
|
||||
, ['FR72508000702383844671J92', false]
|
||||
, ['NL13ABNA2859176594', true]
|
||||
, ['NL51RABO8584700412', true]
|
||||
, ['NL03ABNA4880983179', true]
|
||||
, ['NL13ABNA285917694', false]
|
||||
, ['NL51RABO858470012', false]
|
||||
, ['N03ABNA488098379L', false]
|
||||
, ['BE59561771574126', true]
|
||||
, ['BE02631697478740', true]
|
||||
, ['BE92519646539923', true]
|
||||
, ['BE92519646539923', true]
|
||||
, ['111459561771574126', false]
|
||||
, ['1114026316974787401114', false]
|
||||
, ['1114925196465399231114', false]
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @testDoc test the iban_check function
|
||||
* @dataProvider dataCheck_Iban()
|
||||
*/
|
||||
#[DataProvider('dataCheck_Iban')]
|
||||
function testCheck_Iban($iban,$result)
|
||||
{
|
||||
$this->assertTrue(check_iban($iban) == $result," fails for {$iban} receives {$result}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
189
unit-test/include/lib/data_newsqlTest.php
Normal file
189
unit-test/include/lib/data_newsqlTest.php
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
* NOALYSS 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.
|
||||
*
|
||||
* NOALYSS 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 NOALYSS; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
// Copyright Author Dany De Bontridder danydb@aevalys.eu 22/10/23
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief New syntax for Table_Data_SQL
|
||||
*/
|
||||
|
||||
class Currency_SQL extends \Table_Data_SQL
|
||||
{
|
||||
function __construct(Database $p_cn, $p_id=-1)
|
||||
{
|
||||
$this->table="public.currency";
|
||||
$this->primary_key="id";
|
||||
/*
|
||||
* List of columns
|
||||
*/
|
||||
$this->name=array(
|
||||
"id"
|
||||
, "cr_code_iso"
|
||||
,"cr_name"
|
||||
);
|
||||
/*
|
||||
* Type of columns
|
||||
*/
|
||||
$this->type=array(
|
||||
"id"=>"numeric"
|
||||
, "cr_code_iso"=>"text"
|
||||
, "cr_name"=>"text"
|
||||
);
|
||||
|
||||
|
||||
$this->default=array(
|
||||
"id"=>"auto"
|
||||
);
|
||||
|
||||
$this->date_format="DD.MM.YYYY";
|
||||
parent::__construct($p_cn, $p_id);
|
||||
}
|
||||
}
|
||||
class Data_NewSQLTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox create object currency_sql
|
||||
*/
|
||||
function testBuildObject()
|
||||
{
|
||||
$cn=new \Database(DOSSIER);
|
||||
$currency_sql = new Currency_SQL($cn,0);
|
||||
$this->assertEquals($currency_sql->cr_code_iso,'EUR','invalid ISO Code');
|
||||
}
|
||||
/**
|
||||
* @testdox Insert , update and delete row
|
||||
*/
|
||||
function testDMLObject()
|
||||
{
|
||||
/* insert */
|
||||
$cn=new \Database(DOSSIER);
|
||||
$currency_sql = new Currency_SQL($cn);
|
||||
$currency_sql->cr_code_iso = 'XIU';
|
||||
$currency_sql->cr_name = 'Currency for UNIT TEST';
|
||||
$currency_sql->insert();
|
||||
$this->assertTrue($currency_sql->id > 0,' row not created');
|
||||
/* update */
|
||||
$update_sql = new Currency_SQL($cn,$currency_sql->id);
|
||||
$this->assertTrue($update_sql->cr_code_iso=='XIU'," update can not find row");
|
||||
$update_sql->cr_name='xxxx';
|
||||
$update_sql->save();
|
||||
$check_sql=new Currency_SQL($cn,$currency_sql->id);
|
||||
$this->assertEquals($check_sql->get('cr_name'),'xxxx','get row not updated');
|
||||
$this->assertEquals($check_sql->cr_name,'xxxx',' __get row not updated');
|
||||
$this->assertEquals($check_sql->getp('cr_name'),'xxxx',' getp row not updated');
|
||||
/**
|
||||
* delete
|
||||
*/
|
||||
$check_sql->delete();
|
||||
$update_sql->load();
|
||||
$this->assertTrue($update_sql->id < 0,' row not deleted');
|
||||
}
|
||||
/**
|
||||
* @testdox __get an unknow col
|
||||
*/
|
||||
function testGetUnknowCol1()
|
||||
{
|
||||
try {
|
||||
$cn=new \Database(DOSSIER);
|
||||
$currency_sql = new Currency_SQL($cn,0);
|
||||
$a=$currency_sql->dummy;
|
||||
$currency_sql->save();
|
||||
|
||||
} catch (Exception $ex) {
|
||||
$this->assertEquals($ex->getCode(), EXC_DATA_SQL,' get unknow column fails');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @testdox get an unknow col
|
||||
*/
|
||||
function testGetUnknowCol2()
|
||||
{
|
||||
try {
|
||||
$cn=new \Database(DOSSIER);
|
||||
$currency_sql = new Currency_SQL($cn,0);
|
||||
$currency_sql->get("dummy");
|
||||
$currency_sql->save();
|
||||
|
||||
} catch (Exception $ex) {
|
||||
$this->assertEquals($ex->getCode(), EXC_DATA_SQL,' get unknow column fails');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @testdox getp an unknow col
|
||||
*/
|
||||
function testGetUnknowCol3()
|
||||
{
|
||||
try {
|
||||
$cn=new \Database(DOSSIER);
|
||||
$currency_sql = new Currency_SQL($cn,0);
|
||||
$currency_sql->getp("dummy");
|
||||
$currency_sql->save();
|
||||
|
||||
} catch (Exception $ex) {
|
||||
$this->assertEquals($ex->getCode(), EXC_DATA_SQL,' get unknow column fails');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @testdox __set an unknow col
|
||||
*/
|
||||
function testSetUnknowCol1()
|
||||
{
|
||||
try {
|
||||
$cn=new \Database(DOSSIER);
|
||||
$currency_sql = new Currency_SQL($cn,0);
|
||||
$currency_sql->dummy=1;
|
||||
$currency_sql->save();
|
||||
|
||||
} catch (Exception $ex) {
|
||||
$this->assertEquals($ex->getCode(), EXC_DATA_SQL,' get unknow column fails');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @testdox set an unknow col
|
||||
*/
|
||||
function testSetUnknowCol2()
|
||||
{
|
||||
try {
|
||||
$cn=new \Database(DOSSIER);
|
||||
$currency_sql = new Currency_SQL($cn,0);
|
||||
$currency_sql->set("dummy",1);
|
||||
$currency_sql->save();
|
||||
|
||||
} catch (Exception $ex) {
|
||||
$this->assertEquals($ex->getCode(), EXC_DATA_SQL,' get unknow column fails');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @testdox setp an unknow col
|
||||
*/
|
||||
function testSetUnknowCol3()
|
||||
{
|
||||
try {
|
||||
$cn=new \Database(DOSSIER);
|
||||
$currency_sql = new Currency_SQL($cn,0);
|
||||
$currency_sql->setp("dummy",1);
|
||||
$currency_sql->save();
|
||||
|
||||
} catch (Exception $ex) {
|
||||
$this->assertEquals($ex->getCode(), EXC_DATA_SQL,' get unknow column fails');
|
||||
}
|
||||
}
|
||||
}
|
||||
193
unit-test/include/lib/data_sqlTest.php
Normal file
193
unit-test/include/lib/data_sqlTest.php
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
* NOALYSS 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.
|
||||
*
|
||||
* NOALYSS 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 NOALYSS; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
// Copyright Author Dany De Bontridder danydb@aevalys.eu 22/10/23
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
/**
|
||||
* @file
|
||||
* @brief Test Data_SQL
|
||||
*/
|
||||
require DIRTEST.'/global.php';
|
||||
|
||||
class data_Currency_SQL extends \Table_Data_SQL
|
||||
{
|
||||
|
||||
function __construct(Database $p_cn, $p_id=-1)
|
||||
{
|
||||
$this->table="public.currency";
|
||||
$this->primary_key="id";
|
||||
/*
|
||||
* List of columns
|
||||
*/
|
||||
$this->name=array(
|
||||
"id"=>"id"
|
||||
, "cr_code_iso"=>"cr_code_iso"
|
||||
,"cr_name"=>"cr_name"
|
||||
);
|
||||
/*
|
||||
* Type of columns
|
||||
*/
|
||||
$this->type=array(
|
||||
"id"=>"numeric"
|
||||
, "cr_code_iso"=>"text"
|
||||
, "cr_name"=>"text"
|
||||
);
|
||||
|
||||
|
||||
$this->default=array(
|
||||
"id"=>"auto"
|
||||
);
|
||||
|
||||
$this->date_format="DD.MM.YYYY";
|
||||
parent::__construct($p_cn, $p_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Data_SQLTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @testdox create object currency_sql
|
||||
*/
|
||||
function testBuildObject()
|
||||
{
|
||||
$cn=new \Database(DOSSIER);
|
||||
$currency_sql = new data_Currency_SQL($cn,0);
|
||||
$this->assertEquals($currency_sql->cr_code_iso,'EUR','invalid ISO Code');
|
||||
}
|
||||
/**
|
||||
* @testdox Insert , update and delete row
|
||||
*/
|
||||
function testDMLObject()
|
||||
{
|
||||
/* insert */
|
||||
$cn=new \Database(DOSSIER);
|
||||
$currency_sql = new data_Currency_SQL($cn);
|
||||
$currency_sql->cr_code_iso = 'XIU';
|
||||
$currency_sql->cr_name = 'Currency for UNIT TEST';
|
||||
$currency_sql->insert();
|
||||
$this->assertTrue($currency_sql->id > 0,' row not created');
|
||||
/* update */
|
||||
$update_sql = new data_Currency_SQL($cn,$currency_sql->id);
|
||||
$this->assertTrue($update_sql->cr_code_iso=='XIU'," update can not find row");
|
||||
$update_sql->cr_name='xxxx';
|
||||
$update_sql->save();
|
||||
$check_sql=new data_Currency_SQL($cn,$currency_sql->id);
|
||||
$this->assertEquals($check_sql->get('cr_name'),'xxxx','get row not updated');
|
||||
$this->assertEquals($check_sql->cr_name,'xxxx',' __get row not updated');
|
||||
$this->assertEquals($check_sql->getp('cr_name'),'xxxx',' getp row not updated');
|
||||
/**
|
||||
* delete
|
||||
*/
|
||||
$check_sql->delete();
|
||||
$update_sql->load();
|
||||
$this->assertTrue($update_sql->id < 0,' row not deleted');
|
||||
}
|
||||
/**
|
||||
* @testdox __get an unknow col
|
||||
*/
|
||||
function testGetUnknowCol1()
|
||||
{
|
||||
try {
|
||||
$cn=new \Database(DOSSIER);
|
||||
$currency_sql = new data_Currency_SQL($cn,0);
|
||||
$a=$currency_sql->dummy;
|
||||
$currency_sql->save();
|
||||
|
||||
} catch (Exception $ex) {
|
||||
$this->assertEquals($ex->getCode(), EXC_DATA_SQL,' get unknow column fails');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @testdox get an unknow col
|
||||
*/
|
||||
function testGetUnknowCol2()
|
||||
{
|
||||
try {
|
||||
$cn=new \Database(DOSSIER);
|
||||
$currency_sql = new data_Currency_SQL($cn,0);
|
||||
$currency_sql->get("dummy");
|
||||
$currency_sql->save();
|
||||
|
||||
} catch (Exception $ex) {
|
||||
$this->assertEquals($ex->getCode(), EXC_DATA_SQL,' get unknow column fails');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @testdox getp an unknow col
|
||||
*/
|
||||
function testGetUnknowCol3()
|
||||
{
|
||||
try {
|
||||
$cn=new \Database(DOSSIER);
|
||||
$currency_sql = new data_Currency_SQL($cn,0);
|
||||
$currency_sql->getp("dummy");
|
||||
$currency_sql->save();
|
||||
|
||||
} catch (Exception $ex) {
|
||||
$this->assertEquals($ex->getCode(), EXC_DATA_SQL,' get unknow column fails');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @testdox __set an unknow col
|
||||
*/
|
||||
function testSetUnknowCol1()
|
||||
{
|
||||
try {
|
||||
$cn=new \Database(DOSSIER);
|
||||
$currency_sql = new data_Currency_SQL($cn,0);
|
||||
$currency_sql->dummy=1;
|
||||
$currency_sql->save();
|
||||
|
||||
} catch (Exception $ex) {
|
||||
$this->assertEquals($ex->getCode(), EXC_DATA_SQL,' get unknow column fails');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @testdox set an unknow col
|
||||
*/
|
||||
function testSetUnknowCol2()
|
||||
{
|
||||
try {
|
||||
$cn=new \Database(DOSSIER);
|
||||
$currency_sql = new data_Currency_SQL($cn,0);
|
||||
$currency_sql->set("dummy",1);
|
||||
$currency_sql->save();
|
||||
|
||||
} catch (Exception $ex) {
|
||||
$this->assertEquals($ex->getCode(), EXC_DATA_SQL,' get unknow column fails');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @testdox setp an unknow col
|
||||
*/
|
||||
function testSetUnknowCol3()
|
||||
{
|
||||
try {
|
||||
$cn=new \Database(DOSSIER);
|
||||
$currency_sql = new data_Currency_SQL($cn,0);
|
||||
$currency_sql->setp("dummy",1);
|
||||
$currency_sql->save();
|
||||
|
||||
} catch (Exception $ex) {
|
||||
$this->assertEquals($ex->getCode(), EXC_DATA_SQL,' get unknow column fails');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -29,7 +29,6 @@ use PHPUnit\Framework\TestCase;
|
|||
* Generated by PHPUnit_SkeletonGenerator on 2016-02-11 at 15:41:40.
|
||||
*/
|
||||
class DatabaseCoreTest extends TestCase
|
||||
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
@ -124,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");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
*/
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
require DIRTEST . '/global.php';
|
||||
|
||||
/**
|
||||
|
|
@ -44,7 +44,7 @@ class Http_InputTest extends TestCase {
|
|||
|
||||
* @return array
|
||||
*/
|
||||
function dataHttpInput() {
|
||||
static function dataHttpInput() {
|
||||
return array(
|
||||
[ ['value'=>'<script'], '<.script']
|
||||
, [['value'=>'Test <script'], 'Test <.script']
|
||||
|
|
@ -63,6 +63,7 @@ class Http_InputTest extends TestCase {
|
|||
* @dataProvider dataHttpInput
|
||||
* @global $g_connection
|
||||
*/
|
||||
#[DataProvider('dataHttpInput')]
|
||||
function testRemoveHarmingString($array,$result) {
|
||||
$http=new \HttpInput();
|
||||
// print "value = ".print_r($value,true);
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ VALUES(1, 'ACTIVITE', 'Activité commerciale Alchimerys sprl');
|
|||
public function testbuild_query()
|
||||
{
|
||||
$str=$this->object->build_query();
|
||||
$expected=" select po_id,po_name,pa_id,po_amount,po_description,ga_id,po_state from public.poste_analytique where po_id = $1";
|
||||
$expected=" select po_id,po_name,pa_id,po_amount,po_description,ga_id,po_state from public.poste_analytique";
|
||||
$this->assertEquals($str,$expected);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue