Merge branch '8.0' of git@github.com:Dolibarr/dolibarr.git into develop
Conflicts: ChangeLog htdocs/core/modules/modStripe.class.php htdocs/filefunc.inc.php htdocs/projet/element.php
This commit is contained in:
commit
5bd538fb2c
1
.gitignore
vendored
1
.gitignore
vendored
@ -12,6 +12,7 @@ dolibarr_install.log
|
||||
upgrade.log
|
||||
doxygen_warnings.log
|
||||
/.project
|
||||
/.vscode
|
||||
.DS_Store
|
||||
.idea
|
||||
*.iml
|
||||
|
||||
34
ChangeLog
34
ChangeLog
@ -25,6 +25,40 @@ Following changes may create regressions for some external modules, but were nec
|
||||
|
||||
|
||||
|
||||
***** ChangeLog for 8.0.2 compared to 8.0.1 *****
|
||||
FIX: #8452
|
||||
FIX: #9043
|
||||
FIX: #9316 Error when listing invoices
|
||||
FIX: #9317
|
||||
FIX: #9353 Bug: html error - div inside span on graphs
|
||||
FIX: #9355
|
||||
FIX: #9393 inconsistency behaviour. option FACTURE_ENABLE_NEGATIVE_LINES
|
||||
FIX: #9394
|
||||
FIX: #9396
|
||||
FIX: #9403
|
||||
FIX: #9412
|
||||
FIX: #9497
|
||||
FIX: Add paypal error message in alert email when online payment fails.
|
||||
FIX: better compatibility with multicompany
|
||||
FIX: capital must be empty and not 0 if undefined
|
||||
FIX: character making error on bill list
|
||||
FIX: Entering negative price on order.
|
||||
FIX: Expedition not showing extrafields on creation.
|
||||
FIX: Homepage links were using wrong topmenus
|
||||
FIX: inconsistency behaviour on option FACTURE_ENABLE_NEGATIVE_LINES
|
||||
FIX: invert mime type and name.
|
||||
FIX: invoice popup hide localtax2 and 3 if not defined.
|
||||
FIX: Lose filter on payment type or category after a sort on invoice list.
|
||||
FIX: Maxi debug to allow to load chart of account with multicompany.
|
||||
FIX: Missing translation in predefined email to membership renewal.
|
||||
FIX: Mixing tickets of different thirdparties.
|
||||
FIX: "Other ..." link so the "Back to" link works.
|
||||
FIX: PDF address: handle when contact thirdparty is different from thirdparty of document
|
||||
FIX: Problems with permissions of module to record payment of salaries
|
||||
FIX: remove debug
|
||||
FIX: Several fixes on the management of minimal amount for orders
|
||||
FIX: wrong var name
|
||||
|
||||
***** ChangeLog for 8.0.1 compared to 8.0.0 *****
|
||||
FIX: #9258
|
||||
FIX: #9328
|
||||
|
||||
@ -846,6 +846,8 @@ if ($mode == 'common')
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
print '<br>';
|
||||
|
||||
// Show warning about external users
|
||||
print info_admin(showModulesExludedForExternal($modules))."\n";
|
||||
|
||||
|
||||
@ -156,7 +156,8 @@ $i=0;
|
||||
foreach($_SESSION as $key => $val)
|
||||
{
|
||||
if ($i > 0) print ', ';
|
||||
print $key.' => '.dol_escape_htmltag($val);
|
||||
if (is_array($val)) print $key.' => array(...)';
|
||||
else print $key.' => '.dol_escape_htmltag($val);
|
||||
$i++;
|
||||
}
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
@ -666,6 +666,8 @@ if ($object->id > 0)
|
||||
*/
|
||||
if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
|
||||
{
|
||||
$langs->load("propal");
|
||||
|
||||
$sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht";
|
||||
$sql.= ", p.tva as total_tva";
|
||||
$sql.= ", p.total as total_ttc";
|
||||
@ -674,7 +676,7 @@ if ($object->id > 0)
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c";
|
||||
$sql.= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id";
|
||||
$sql.= " AND s.rowid = ".$object->id;
|
||||
$sql.= " AND p.entity = ".$conf->entity;
|
||||
$sql.= " AND p.entity IN (".getEntity('propal').")";
|
||||
$sql.= " ORDER BY p.datep DESC";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* 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
|
||||
@ -1032,6 +1033,7 @@ class Propal extends CommonObject
|
||||
// Add linked object (deprecated, use ->linkedObjectsIds instead)
|
||||
if (! $error && $this->origin && $this->origin_id)
|
||||
{
|
||||
dol_syslog('Deprecated use of linked object, use ->linkedObjectsIds instead', LOG_WARNING);
|
||||
$ret = $this->add_object_linked();
|
||||
if (! $ret) dol_print_error($this->db);
|
||||
}
|
||||
@ -1104,13 +1106,6 @@ class Propal extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
// Add linked object
|
||||
if (! $error && $this->origin && $this->origin_id)
|
||||
{
|
||||
$ret = $this->add_object_linked();
|
||||
if (! $ret) dol_print_error($this->db);
|
||||
}
|
||||
|
||||
// Set delivery address
|
||||
if (! $error && $this->fk_delivery_address)
|
||||
{
|
||||
|
||||
@ -958,7 +958,7 @@ class FormMail extends Form
|
||||
if (count($validpaymentmethod) > 0 && $paymenturl)
|
||||
{
|
||||
$langs->load('other');
|
||||
$this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__']=str_replace('\n',"\n",$langs->transnoentities("PredefinedMailContentLink", $paymenturl));
|
||||
$this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__']=str_replace('\n', "\n", $langs->transnoentities("PredefinedMailContentLink", $paymenturl));
|
||||
$this->substit['__ONLINE_PAYMENT_URL__']=$paymenturl;
|
||||
}
|
||||
else
|
||||
|
||||
@ -4175,13 +4175,13 @@ function print_fiche_titre($title, $mesg='', $picto='title_generic.png', $pictoi
|
||||
* @param string $morehtmlright Added message to show on right
|
||||
* @param string $picto Icon to use before title (should be a 32x32 transparent png file)
|
||||
* @param int $pictoisfullpath 1=Icon name is a full absolute url of image
|
||||
* @param int $id To force an id on html objects
|
||||
* @param string $id To force an id on html objects
|
||||
* @param string $morecssontable More css on table
|
||||
* @param string $morehtmlcenter Added message to show on center
|
||||
* @return string
|
||||
* @see print_barre_liste
|
||||
*/
|
||||
function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
|
||||
function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -4191,7 +4191,7 @@ function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png',
|
||||
|
||||
$return.= "\n";
|
||||
$return.= '<table '.($id?'id="'.$id.'" ':'').'summary="" class="centpercent notopnoleftnoright'.($morecssontable?' '.$morecssontable:'').'" style="margin-bottom: 2px;"><tr>';
|
||||
if ($picto) $return.= '<td class="nobordernopadding widthpictotitle opacityhigh" valign="middle">'.img_picto('',$picto, 'class="valignmiddle widthpictotitle" id="pictotitle"', $pictoisfullpath).'</td>';
|
||||
if ($picto) $return.= '<td class="nobordernopadding widthpictotitle opacityhigh" valign="middle">'.img_picto('',$picto, 'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).'</td>';
|
||||
$return.= '<td class="nobordernopadding" valign="middle">';
|
||||
$return.= '<div class="titre">'.$titre.'</div>';
|
||||
$return.= '</td>';
|
||||
@ -6110,7 +6110,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
|
||||
$paymenturl=$url;
|
||||
}
|
||||
|
||||
$substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__']=($paymenturl?$outputlangs->trans("PredefinedMailContentLink", $paymenturl):'');
|
||||
$substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__']=($paymenturl?str_replace('\n', "\n", $outputlangs->trans("PredefinedMailContentLink", $paymenturl)):'');
|
||||
$substitutionarray['__ONLINE_PAYMENT_URL__']=$paymenturl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2017-2018 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* 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
|
||||
@ -887,7 +888,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
$pdf->SetXY($col1x, $tab2_top + 0);
|
||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
|
||||
|
||||
$total_ht = (($conf->multicurrency->enabled && isset($object->mylticurrency_tx) && $object->mylticurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
|
||||
$total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
|
||||
$pdf->SetXY($col2x, $tab2_top + 0);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2017-2018 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* 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
|
||||
@ -1117,7 +1118,7 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$pdf->SetXY($col1x, $tab2_top + 0);
|
||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
|
||||
|
||||
$total_ht = (($conf->multicurrency->enabled && isset($object->mylticurrency_tx) && $object->mylticurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
|
||||
$total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
|
||||
$pdf->SetXY($col2x, $tab2_top + 0);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1);
|
||||
|
||||
|
||||
@ -50,7 +50,9 @@ class modSalaries extends DolibarrModules
|
||||
$this->db = $db;
|
||||
$this->numero = 510; // Perms from 501..519
|
||||
|
||||
$this->family = "compta";
|
||||
// Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
|
||||
// It is used to group modules by family in module setup page
|
||||
$this->family = "financial";
|
||||
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
||||
$this->name = preg_replace('/^mod/i','',get_class($this));
|
||||
// Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2017-2018 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* 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
|
||||
@ -1064,7 +1065,7 @@ class pdf_azur extends ModelePDFPropales
|
||||
$pdf->SetXY($col1x, $tab2_top + 0);
|
||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
|
||||
|
||||
$total_ht = (($conf->multicurrency->enabled && isset($object->mylticurrency_tx) && $object->mylticurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
|
||||
$total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
|
||||
$pdf->SetXY($col2x, $tab2_top + 0);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
/* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* 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
|
||||
@ -648,7 +649,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
|
||||
$pdf->SetXY($col1x, $tab2_top + 0);
|
||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
|
||||
|
||||
$total_ht = (($conf->multicurrency->enabled && isset($object->mylticurrency_tx) && $object->mylticurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
|
||||
$total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
|
||||
$pdf->SetXY($col2x, $tab2_top + 0);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + $object->remise), 0, 'R', 1);
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* 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
|
||||
@ -821,7 +822,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
$pdf->SetXY($col1x, $tab2_top + 0);
|
||||
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
|
||||
|
||||
$total_ht = (($conf->multicurrency->enabled && isset($object->mylticurrency_tx) && $object->mylticurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
|
||||
$total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
|
||||
$pdf->SetXY($col2x, $tab2_top + 0);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0)), 0, 'R', 1);
|
||||
|
||||
|
||||
@ -73,10 +73,10 @@ BoxProposalsPerMonth=Proposals per month
|
||||
NoTooLowStockProducts=No products are under the low stock limit
|
||||
BoxProductDistribution=Products/Services Distribution
|
||||
BoxProductDistributionFor=Distribution of %s by %s
|
||||
BoxTitleLastModifiedSupplierBills=Supplier Invoices: last %s modified
|
||||
BoxTitleLatestModifiedSupplierOrders=Supplier Orders: last %s modified
|
||||
BoxTitleLastModifiedCustomerBills=Customer Invoices: last %s modified
|
||||
BoxTitleLastModifiedCustomerOrders=Customer Orders: last %s modified
|
||||
BoxTitleLastModifiedSupplierBills=Latest %s modified vendors invoices
|
||||
BoxTitleLatestModifiedSupplierOrders=Last %s modified purchase orders
|
||||
BoxTitleLastModifiedCustomerBills=Latest %s modified customers invoices
|
||||
BoxTitleLastModifiedCustomerOrders=Latest %s modified customer orders
|
||||
BoxTitleLastModifiedPropals=Latest %s modified proposals
|
||||
ForCustomersInvoices=Customers invoices
|
||||
ForCustomersOrders=Customers orders
|
||||
|
||||
@ -328,7 +328,7 @@ Copy=Copy
|
||||
Paste=Paste
|
||||
Default=Default
|
||||
DefaultValue=Default value
|
||||
DefaultValues=Default values
|
||||
DefaultValues=Default values/filters/sorting
|
||||
Price=Price
|
||||
PriceCurrency=Price (currency)
|
||||
UnitPrice=Unit price
|
||||
|
||||
@ -327,7 +327,7 @@ Copy=Copier
|
||||
Paste=Coller
|
||||
Default=Défaut
|
||||
DefaultValue=Valeur par défaut
|
||||
DefaultValues=Valeurs par défaut
|
||||
DefaultValues=Valeurs/Filtres/Tri par défaut
|
||||
Price=Prix
|
||||
PriceCurrency=Prix (devise)
|
||||
UnitPrice=Prix unitaire
|
||||
|
||||
@ -454,6 +454,36 @@ class Loan extends CommonObject
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise an instance with random values.
|
||||
* Used to build previews or test instances.
|
||||
* id must be 0 if object instance is a specimen.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function initAsSpecimen()
|
||||
{
|
||||
global $user, $langs, $conf;
|
||||
|
||||
$now=dol_now();
|
||||
|
||||
// Initialise parameters
|
||||
$this->id = 0;
|
||||
$this->fk_bank = 1;
|
||||
$this->label = 'SPECIMEN';
|
||||
$this->specimen = 1;
|
||||
$this->socid = 1;
|
||||
$this->account_capital = 16;
|
||||
$this->account_insurance = 616;
|
||||
$this->account_interest = 518;
|
||||
$this->datestart = $now;
|
||||
$this->dateend = $now + (3600 * 24 * 365);
|
||||
$this->note_public = 'SPECIMEN';
|
||||
$this->capital = 20000;
|
||||
$this->nbterm = 48;
|
||||
$this->rate = 4.3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return amount of payments already done
|
||||
|
||||
@ -712,6 +712,9 @@ foreach ($listofreferent as $key => $value)
|
||||
$testnew=$value['testnew'];
|
||||
$project_field=$value['project_field'];
|
||||
|
||||
$exclude_select_element = array('payment_various');
|
||||
if (!empty($value['exclude_select_element'])) $exclude_select_element[] = $value['exclude_select_element'];
|
||||
|
||||
if ($qualified)
|
||||
{
|
||||
// If we want the project task array to have details of users
|
||||
@ -731,7 +734,7 @@ foreach ($listofreferent as $key => $value)
|
||||
if (! empty($conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS)) $idtofilterthirdparty.=','.$conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS;
|
||||
}
|
||||
|
||||
if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename, array('payment_various')))
|
||||
if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename,$exclude_select_element))
|
||||
{
|
||||
$selectList=$formproject->select_element($tablename, $idtofilterthirdparty, 'minwidth300',-2,!empty($project_field)?$project_field:'fk_projet');
|
||||
if (! $selectList || ($selectList<0))
|
||||
|
||||
@ -1378,7 +1378,7 @@ div.nopadding {
|
||||
margin : 0px auto;
|
||||
}
|
||||
|
||||
#pictotitle {
|
||||
.pictotitle {
|
||||
margin-<?php echo $right; ?>: 8px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
@ -1372,7 +1372,7 @@ table.noborder tr.liste_titre td {
|
||||
margin : 0px auto;
|
||||
}
|
||||
|
||||
#pictotitle {
|
||||
.pictotitle {
|
||||
margin-<?php echo $right; ?>: 8px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
@ -195,6 +195,8 @@ class AllTests
|
||||
$suite->addTestSuite('HolidayTest');
|
||||
require_once dirname(__FILE__).'/ExpenseReportTest.php';
|
||||
$suite->addTestSuite('ExpenseReportTest');
|
||||
require_once dirname(__FILE__).'/LoanTest.php';
|
||||
$suite->addTestSuite('LoanTest');
|
||||
|
||||
require_once dirname(__FILE__).'/EntrepotTest.php';
|
||||
$suite->addTestSuite('EntrepotTest');
|
||||
|
||||
218
test/phpunit/LoanTest.php
Normal file
218
test/phpunit/LoanTest.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
/* Copyright (C) 2018 Maxime Kohlhaas <support@atm-consulting.fr>
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file test/phpunit/LoanTest.php
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
|
||||
//require_once 'PHPUnit/Autoload.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/loan/class/loan.class.php';
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
|
||||
/**
|
||||
* Class for PHPUnit tests
|
||||
*
|
||||
* @backupGlobals disabled
|
||||
* @backupStaticAttributes enabled
|
||||
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
|
||||
*/
|
||||
class LoanTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return LoanTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
// tear down after class
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
//print $db->getVersion()."\n";
|
||||
}
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* testLoanCreate
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testLoanCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Loan($this->savdb);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testLoanFetch
|
||||
*
|
||||
* @param int $id Id of object
|
||||
* @return void
|
||||
*
|
||||
* @depends testLoanCreate
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testLoanFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Loan($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testLoanOther
|
||||
*
|
||||
* @param Loan $localobject Loan
|
||||
* @return int
|
||||
*
|
||||
* @depends testLoanFetch
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testLoanOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$result=$localobject->set_paid($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* testLoanDelete
|
||||
*
|
||||
* @param int $id Id of loan
|
||||
* @return void
|
||||
*
|
||||
* @depends testLoanCreate
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testLoanDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Loan($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user