Qual: Add new PHPUnit test and fix bugs the test show me

This commit is contained in:
Laurent Destailleur 2012-03-21 12:33:51 +01:00
parent fc18414228
commit ab6c1a5160
5 changed files with 349 additions and 123 deletions

View File

@ -1,36 +1,34 @@
<?php <?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr> * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** /**
* \file htdocs/compta/bank/class/account.class.php * \file htdocs/compta/bank/class/account.class.php
* \ingroup banque * \ingroup banque
* \brief File of class to manage bank accounts * \brief File of class to manage bank accounts
*/ */
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php"); require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
/** /**
* \class Account * Class to manage bank accounts
* \brief Class to manage bank accounts
*/ */
class Account extends CommonObject class Account extends CommonObject
{ {
@ -46,7 +44,7 @@ class Account extends CommonObject
//! Name //! Name
var $bank; var $bank;
var $clos; var $clos;
var $rappro; // If bank need to be conciliated var $rappro=1; // If bank need to be conciliated
var $url; var $url;
//! BBAN field for French Code banque //! BBAN field for French Code banque
var $code_banque; var $code_banque;
@ -266,12 +264,12 @@ class Account extends CommonObject
// Check parameters // Check parameters
if (! $oper) if (! $oper)
{ {
$this->error="Account::addline oper not defined"; $this->error="oper not defined";
return -1; return -1;
} }
if (! $this->rowid) if (! $this->rowid)
{ {
$this->error="Account::addline this->rowid not defined"; $this->error="this->rowid not defined";
return -2; return -2;
} }
if ($this->courant == 2 && $oper != 'LIQ') if ($this->courant == 2 && $oper != 'LIQ')
@ -309,7 +307,7 @@ class Account extends CommonObject
$sql.= ", ".($banque?"'".$this->db->escape($banque)."'":"null"); $sql.= ", ".($banque?"'".$this->db->escape($banque)."'":"null");
$sql.= ")"; $sql.= ")";
dol_syslog("Account::addline sql=".$sql); dol_syslog(get_class($this)."::addline sql=".$sql);
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$rowid = $this->db->last_insert_id(MAIN_DB_PREFIX."bank"); $rowid = $this->db->last_insert_id(MAIN_DB_PREFIX."bank");
@ -337,7 +335,7 @@ class Account extends CommonObject
else else
{ {
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
dol_syslog("Account::addline ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::addline ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
} }
@ -353,19 +351,29 @@ class Account extends CommonObject
{ {
global $langs,$conf; global $langs,$conf;
// Check parameters // Clean parameters
if (! $this->min_allowed) $this->min_allowed=0; if (! $this->min_allowed) $this->min_allowed=0;
if (! $this->min_desired) $this->min_desired=0; if (! $this->min_desired) $this->min_desired=0;
if (empty($this->fk_pays)) $this->state_id = ($this->state_id?$this->state_id:$this->fk_departement);
$this->country_id = ($this->country_id?$this->country_id:$this->fk_pays);
// Check parameters
if (empty($this->country_id))
{ {
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Country")); $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Country"));
dol_syslog("Account::update ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
return -1; return -1;
} }
if (empty($this->ref)) if (empty($this->ref))
{ {
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")); $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref"));
dol_syslog("Account::update ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
return -1;
}
if (empty($this->date_solde))
{
$this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("DateInitialBalance"));
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
return -1; return -1;
} }
@ -398,43 +406,48 @@ class Account extends CommonObject
$sql.= ", ".price2num($this->min_allowed); $sql.= ", ".price2num($this->min_allowed);
$sql.= ", ".price2num($this->min_desired); $sql.= ", ".price2num($this->min_desired);
$sql.= ", '".$this->db->escape($this->comment)."'"; $sql.= ", '".$this->db->escape($this->comment)."'";
$sql.= ", ".($this->fk_departement>0?"'".$this->fk_departement."'":"null"); $sql.= ", ".($this->state_id>0?"'".$this->state_id."'":"null");
$sql.= ", ".$this->fk_pays; $sql.= ", ".$this->country_id;
$sql.= ")"; $sql.= ")";
dol_syslog("Account::create sql=".$sql); dol_syslog(get_class($this)."::create sql=".$sql);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
if ($this->db->affected_rows($resql)) $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_account");
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_account");
if ( $this->update() )
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (";
$sql.= "datec";
$sql.= ", label";
$sql.= ", amount";
$sql.= ", fk_account";
$sql.= ", datev";
$sql.= ", dateo";
$sql.= ", fk_type";
$sql.= ", rappro";
$sql.= ") VALUES (";
$sql.= $this->db->idate($now);
$sql.= ", '(".$langs->trans("InitialBankBalance").")'";
$sql.= ", ".price2num($this->solde);
$sql.= ", '".$this->id."'";
$sql.= ", '".$this->db->idate($this->date_solde)."'";
$sql.= ", '".$this->db->idate($this->date_solde)."'";
$sql.= ", 'SOLD'";
$sql.= ", 0"; // Not conciliated by default
$sql.= ")";
$this->db->query($sql); $result=$this->update();
if ($result > 0)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank (";
$sql.= "datec";
$sql.= ", label";
$sql.= ", amount";
$sql.= ", fk_account";
$sql.= ", datev";
$sql.= ", dateo";
$sql.= ", fk_type";
$sql.= ", rappro";
$sql.= ") VALUES (";
$sql.= "'".$this->db->idate($now)."'";
$sql.= ", '(".$langs->trans("InitialBankBalance").")'";
$sql.= ", ".price2num($this->solde);
$sql.= ", '".$this->id."'";
$sql.= ", '".$this->db->idate($this->date_solde)."'";
$sql.= ", '".$this->db->idate($this->date_solde)."'";
$sql.= ", 'SOLD'";
$sql.= ", 0"; // Not conciliated by default
$sql.= ")";
$resql=$this->db->query($sql);
if (! $resql)
{
$this->error=$this->db->lasterror();
dol_syslog($this->error, LOG_ERR);
return -3;
} }
return $this->id;
} }
return $this->id;
} }
else else
{ {
@ -462,19 +475,23 @@ class Account extends CommonObject
{ {
global $langs,$conf; global $langs,$conf;
// Check parameters // Clean parameters
if (! $this->min_allowed) $this->min_allowed=0; if (! $this->min_allowed) $this->min_allowed=0;
if (! $this->min_desired) $this->min_desired=0; if (! $this->min_desired) $this->min_desired=0;
if (empty($this->fk_pays)) $this->state_id = ($this->state_id?$this->state_id:$this->fk_departement);
$this->country_id = ($this->country_id?$this->country_id:$this->fk_pays);
// Check parameters
if (empty($this->country_id))
{ {
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Country")); $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Country"));
dol_syslog("Account::update ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
return -1; return -1;
} }
if (empty($this->ref)) if (empty($this->ref))
{ {
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")); $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref"));
dol_syslog("Account::update ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
return -1; return -1;
} }
if (! $this->label) $this->label = "???"; if (! $this->label) $this->label = "???";
@ -496,13 +513,13 @@ class Account extends CommonObject
$sql.= ",min_desired = '".price2num($this->min_desired)."'"; $sql.= ",min_desired = '".price2num($this->min_desired)."'";
$sql.= ",comment = '".$this->db->escape($this->comment)."'"; $sql.= ",comment = '".$this->db->escape($this->comment)."'";
$sql.= ",fk_departement = ".($this->fk_departement>0?"'".$this->fk_departement."'":"null"); $sql.= ",fk_departement = ".($this->state_id>0?"'".$this->state_id."'":"null");
$sql.= ",fk_pays = ".$this->fk_pays; $sql.= ",fk_pays = ".$this->country_id;
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
dol_syslog("Account::update sql=".$sql); dol_syslog(get_class($this)."::update sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
@ -527,15 +544,19 @@ class Account extends CommonObject
{ {
global $conf,$langs; global $conf,$langs;
// Clean parameters
$this->state_id = ($this->state_id?$this->state_id:$this->fk_departement);
$this->country_id = ($this->country_id?$this->country_id:$this->fk_pays);
// Chargement librairie pour acces fonction controle RIB // Chargement librairie pour acces fonction controle RIB
require_once(DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php');
dol_syslog("Account::update_bban $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban"); dol_syslog(get_class($this)."::update_bban $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban");
// Check parameters // Check parameters
if (! $this->ref) if (! $this->ref)
{ {
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Ref")); $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->trans("Ref"));
return -2; return -2;
} }
@ -550,12 +571,12 @@ class Account extends CommonObject
$sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'"; $sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'";
$sql.= ",proprio = '".$this->db->escape($this->proprio)."'"; $sql.= ",proprio = '".$this->db->escape($this->proprio)."'";
$sql.= ",adresse_proprio = '".$this->db->escape($this->adresse_proprio)."'"; $sql.= ",adresse_proprio = '".$this->db->escape($this->adresse_proprio)."'";
$sql.= ",fk_departement = ".($this->fk_departement>0?"'".$this->fk_departement."'":"null"); $sql.= ",fk_departement = ".($this->state_id>0?"'".$this->state_id."'":"null");
$sql.= ",fk_pays = ".$this->fk_pays; $sql.= ",fk_pays = ".$this->country_id;
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
dol_syslog("Account::update_bban sql=$sql"); dol_syslog(get_class($this)."::update_bban sql=$sql");
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
@ -603,7 +624,7 @@ class Account extends CommonObject
if ($id) $sql.= " AND ba.rowid = ".$id; if ($id) $sql.= " AND ba.rowid = ".$id;
if ($ref) $sql.= " AND ba.ref = '".$this->db->escape($ref)."'"; if ($ref) $sql.= " AND ba.ref = '".$this->db->escape($ref)."'";
dol_syslog("Account::fetch sql=".$sql); dol_syslog(get_class($this)."::fetch sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
@ -979,6 +1000,8 @@ class Account extends CommonObject
*/ */
function initAsSpecimen() function initAsSpecimen()
{ {
$this->ref = 'MBA';
$this->label = 'My Bank account';
$this->bank = 'MyBank'; $this->bank = 'MyBank';
$this->courant = 1; $this->courant = 1;
$this->clos = 0; $this->clos = 0;
@ -992,6 +1015,7 @@ class Account extends CommonObject
$this->domiciliation = 'The bank addresse'; $this->domiciliation = 'The bank addresse';
$this->proprio = 'Owner'; $this->proprio = 'Owner';
$this->adresse_proprio = 'Owner address'; $this->adresse_proprio = 'Owner address';
$this->country_id = 1;
} }
} }
@ -1067,7 +1091,7 @@ class AccountLine extends CommonObject
else if ($ref) $sql.= " AND b.rowid='".$ref."'"; else if ($ref) $sql.= " AND b.rowid='".$ref."'";
else $sql.= " AND b.rowid=".$rowid; else $sql.= " AND b.rowid=".$rowid;
dol_syslog("AccountLine::fetch sql=".$sql); dol_syslog(get_class($this)."::fetch sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
@ -1137,12 +1161,12 @@ class AccountLine extends CommonObject
} }
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid=".$this->rowid; $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid=".$this->rowid;
dol_syslog("AccountLine::delete sql=".$sql); dol_syslog(get_class($this)."::delete sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if (! $result) $nbko++; if (! $result) $nbko++;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank WHERE rowid=".$this->rowid; $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank WHERE rowid=".$this->rowid;
dol_syslog("AccountLine::delete sql=".$sql); dol_syslog(get_class($this)."::delete sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if (! $result) $nbko++; if (! $result) $nbko++;
@ -1179,7 +1203,7 @@ class AccountLine extends CommonObject
$this->db->begin(); $this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank=".$this->rowid; $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank=".$this->rowid;
dol_syslog("AccountLine::delete_urls sql=".$sql); dol_syslog(get_class($this)."::delete_urls sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if (! $result) $nbko++; if (! $result) $nbko++;
@ -1213,7 +1237,7 @@ class AccountLine extends CommonObject
$sql.= " dateo='".$this->db->idate($this->dateo)."'"; $sql.= " dateo='".$this->db->idate($this->dateo)."'";
$sql.= " WHERE rowid = ".$this->rowid; $sql.= " WHERE rowid = ".$this->rowid;
dol_syslog("AccountLine::update sql=".$sql); dol_syslog(get_class($this)."::update sql=".$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -1224,7 +1248,7 @@ class AccountLine extends CommonObject
{ {
$this->db->rollback(); $this->db->rollback();
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog("AccountLine::update ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
return -1; return -1;
} }
} }
@ -1247,7 +1271,7 @@ class AccountLine extends CommonObject
$sql.= ", fk_user_rappro = ".$user->id; $sql.= ", fk_user_rappro = ".$user->id;
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
dol_syslog("AccountLine::update_conciliation sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::update_conciliation sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -1261,7 +1285,7 @@ class AccountLine extends CommonObject
$sql.= ", ".$cat; $sql.= ", ".$cat;
$sql.= ")"; $sql.= ")";
dol_syslog("AccountLine::update_conciliation sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::update_conciliation sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
// No error check. Can fail if category already affected // No error check. Can fail if category already affected

View File

@ -3073,6 +3073,7 @@ class Facture extends CommonObject
$this->specimen=1; $this->specimen=1;
$this->socid = 1; $this->socid = 1;
$this->date = $nownotime; $this->date = $nownotime;
$this->date_lim_reglement = $nownotime + 3600 * 24 *30;
$this->cond_reglement_id = 1; $this->cond_reglement_id = 1;
$this->cond_reglement_code = 'RECEP'; $this->cond_reglement_code = 'RECEP';
$this->date_lim_reglement=$this->calculate_date_lim_reglement(); $this->date_lim_reglement=$this->calculate_date_lim_reglement();

View File

@ -723,29 +723,6 @@ class Project extends CommonObject
$now = mktime(); $now = mktime();
// Charge tableau des id de societe socids
$socids = array();
$sql = "SELECT rowid";
$sql.= " FROM " . MAIN_DB_PREFIX . "societe";
$sql.= " WHERE client IN (1, 3)";
$sql.= " AND entity = " . $conf->entity;
$sql.= " LIMIT 10";
$resql = $this->db->query($sql);
if ($resql)
{
$num_socs = $this->db->num_rows($resql);
$i = 0;
while ($i < $num_socs)
{
$i++;
$row = $this->db->fetch_row($resql);
$socids[$i] = $row[0];
}
}
// Charge tableau des produits prodids // Charge tableau des produits prodids
$prodids = array(); $prodids = array();
@ -772,7 +749,7 @@ class Project extends CommonObject
$this->ref = 'SPECIMEN'; $this->ref = 'SPECIMEN';
$this->specimen = 1; $this->specimen = 1;
$socid = rand(1, $num_socs); $socid = rand(1, $num_socs);
$this->socid = $socids[$socid]; $this->socid = 1;
$this->date_c = $now; $this->date_c = $now;
$this->date_m = $now; $this->date_m = $now;
$this->date_start = $now; $this->date_start = $now;

View File

@ -0,0 +1,224 @@
<?php
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file test/phpunit/ContratTest.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/compta/bank/class/account.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;
$langs->load("main");
/**
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
*/
class BankAccountTest extends PHPUnit_Framework_TestCase
{
protected $savconf;
protected $savuser;
protected $savlangs;
protected $savdb;
/**
* Constructor
* We save global variables into local variables
*
* @return BankAccountTest
*/
function BankAccountTest()
{
//$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";
}
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";
}
/**
* End phpunit tests
*
* @return void
*/
protected function tearDown()
{
print __METHOD__."\n";
}
/**
* testContratCreate
*
* @return int
*/
public function testBankAccountCreate()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new Account($this->savdb);
$localobject->initAsSpecimen();
$localobject->date_solde=dol_now();
$result=$localobject->create($user);
print __METHOD__." result=".$result."\n";
$this->assertLessThan($result, 0);
return $result;
}
/**
* testContratFetch
*
* @param int $id Id of contract
* @return int
*
* @depends testContratCreate
* The depends says test is run only if previous is ok
*/
public function testBankAccountFetch($id)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new Account($this->savdb);
$result=$localobject->fetch($id);
print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0);
return $localobject;
}
/**
* testBankAccountFetch
*
* @param Object $localobject Object contract
* @return int
*
* @depends testBankAccountOther
* The depends says test is run only if previous is ok
*/
public function testBankAccountOther($localobject)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
/*$result=$localobject->setstatus(0);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
*/
$localobject->info($localobject->id);
print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n";
$this->assertNotEquals($localobject->date_creation, '');
return $localobject->id;
}
/**
* testBankAccountDelete
*
* @param int $id Id of contract
* @return int
*
* @depends testBankAccountOther
* The depends says test is run only if previous is ok
*/
public function testBankAccountDelete($id)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new Account($this->savdb);
$result=$localobject->fetch($id);
$result=$localobject->delete($id);
print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0);
return $result;
}
}
?>

View File

@ -164,15 +164,22 @@ class BuildDocTest extends PHPUnit_Framework_TestCase
$db=$this->savdb; $db=$this->savdb;
$conf->facture->dir_output.='/temp'; $conf->facture->dir_output.='/temp';
$localobjectcom=new Commande($this->savdb);
$localobjectcom->initAsSpecimen();
$localobject=new Facture($this->savdb); $localobject=new Facture($this->savdb);
$localobject->initAsSpecimen(); $localobject->createFromOrder($localobjectcom);
$localobject->socid=1; $localobject->date_lim_reglement = dol_now() + 3600 * 24 *30;
// Crabe // Crabe
$localobject->modelpdf='crabe'; $localobject->modelpdf='crabe';
$result=facture_pdf_create($db, $localobject, $localobject->modelpdf, $langs); $result=facture_pdf_create($db, $localobject, $localobject->modelpdf, $langs);
$this->assertLessThan($result, 0); $localobject=new Facture($this->savdb);
$localobject->initAsSpecimen();
$this->assertLessThan($result, 0);
print __METHOD__." result=".$result."\n"; print __METHOD__." result=".$result."\n";
// Oursin // Oursin
@ -201,7 +208,6 @@ class BuildDocTest extends PHPUnit_Framework_TestCase
$conf->fournisseur->facture->dir_output.='/temp'; $conf->fournisseur->facture->dir_output.='/temp';
$localobject=new FactureFournisseur($this->savdb); $localobject=new FactureFournisseur($this->savdb);
$localobject->initAsSpecimen(); $localobject->initAsSpecimen();
$localobject->socid=1;
// Canelle // Canelle
$localobject->modelpdf='canelle'; $localobject->modelpdf='canelle';
@ -229,7 +235,6 @@ class BuildDocTest extends PHPUnit_Framework_TestCase
$conf->commande->dir_output.='/temp'; $conf->commande->dir_output.='/temp';
$localobject=new Commande($this->savdb); $localobject=new Commande($this->savdb);
$localobject->initAsSpecimen(); $localobject->initAsSpecimen();
$localobject->socid=1;
// Einstein // Einstein
$localobject->modelpdf='einstein'; $localobject->modelpdf='einstein';
@ -265,7 +270,6 @@ class BuildDocTest extends PHPUnit_Framework_TestCase
$conf->fournisseur->commande->dir_output.='/temp'; $conf->fournisseur->commande->dir_output.='/temp';
$localobject=new CommandeFournisseur($this->savdb); $localobject=new CommandeFournisseur($this->savdb);
$localobject->initAsSpecimen(); $localobject->initAsSpecimen();
$localobject->socid=1;
// Muscadet // Muscadet
$localobject->modelpdf='muscadet'; $localobject->modelpdf='muscadet';
@ -293,7 +297,6 @@ class BuildDocTest extends PHPUnit_Framework_TestCase
$conf->propale->dir_output.='/temp'; $conf->propale->dir_output.='/temp';
$localobject=new Propal($this->savdb); $localobject=new Propal($this->savdb);
$localobject->initAsSpecimen(); $localobject->initAsSpecimen();
$localobject->socid=1;
// Einstein // Einstein
$localobject->modelpdf='azur'; $localobject->modelpdf='azur';
@ -328,7 +331,6 @@ class BuildDocTest extends PHPUnit_Framework_TestCase
$conf->project->dir_output.='/temp'; $conf->project->dir_output.='/temp';
$localobject=new Project($this->savdb); $localobject=new Project($this->savdb);
$localobject->initAsSpecimen(); $localobject->initAsSpecimen();
$localobject->socid=1;
// Soleil // Soleil
$localobject->modelpdf='baleine'; $localobject->modelpdf='baleine';
@ -356,7 +358,6 @@ class BuildDocTest extends PHPUnit_Framework_TestCase
$conf->fichinter->dir_output.='/temp'; $conf->fichinter->dir_output.='/temp';
$localobject=new Fichinter($this->savdb); $localobject=new Fichinter($this->savdb);
$localobject->initAsSpecimen(); $localobject->initAsSpecimen();
$localobject->socid=1;
// Soleil // Soleil
$localobject->modelpdf='soleil'; $localobject->modelpdf='soleil';
@ -384,7 +385,6 @@ class BuildDocTest extends PHPUnit_Framework_TestCase
$conf->expedition->dir_output.='/temp'; $conf->expedition->dir_output.='/temp';
$localobject=new Expedition($this->savdb); $localobject=new Expedition($this->savdb);
$localobject->initAsSpecimen(); $localobject->initAsSpecimen();
$localobject->socid=1;
// Soleil // Soleil
$localobject->modelpdf='merou'; $localobject->modelpdf='merou';