Fix: PHPUnit tests are back.

This commit is contained in:
Laurent Destailleur 2013-03-09 18:55:57 +01:00
parent 7bbbc32af9
commit 3e5ee3b00a
20 changed files with 68 additions and 123 deletions

View File

@ -220,8 +220,11 @@ class Adherent extends CommonObject
// For backward compatibility
'%INFOS%'=>$msgishtml?dol_htmlentitiesbr($infos):$infos,
'%SOCIETE%'=>$msgishtml?dol_htmlentitiesbr($this->societe):$this->societe,
'%ZIP%'=>$msgishtml?dol_htmlentitiesbr($this->zip):$this->zip,
'%COUNTRY%'=>$msgishtml?dol_htmlentitiesbr($this->country):$this->country,
'%PRENOM%'=>$msgishtml?dol_htmlentitiesbr($this->firstname):$this->firstname,
'%NOM%'=>$msgishtml?dol_htmlentitiesbr($this->lastname):$this->lastname,
'%CP%'=>$msgishtml?dol_htmlentitiesbr($this->zip):$this->zip,
'%VILLE%'=>$msgishtml?dol_htmlentitiesbr($this->town):$this->town,
'%PAYS%'=>$msgishtml?dol_htmlentitiesbr($this->country):$this->country,
);
complete_substitutions_array($substitutionarray, $langs);

View File

@ -74,9 +74,9 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
if (! is_object($mysoc)) // mysoc may be not defined (during migration process)
{
$mysoc=new Societe($db);
$mysoc->getMysoc($conf);
$mysoc->setMysoc($conf);
}
$seller=$mysoc; // If seller is a customer, $seller is not provided, we use $mysoc
$seller=$mysoc; // If sell is done to a customer, $seller is not provided, we use $mysoc
//var_dump($seller->country_id);exit;
}

View File

@ -189,7 +189,7 @@ class ExportTsv extends ModeleExports
foreach($array_selected_sorted as $code => $value)
{
$newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);
$newvalue=$this->tsv_clean($newvalue);
$newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
fwrite($this->handle,$newvalue.$this->separator);
}
@ -210,17 +210,17 @@ class ExportTsv extends ModeleExports
function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
{
global $conf;
$this->col=0;
foreach($array_selected_sorted as $code => $value)
{
if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-'),'_',$code);
else $alias=substr($code, strpos($code, ' as ') + 4);
if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
$newvalue=$outputlangs->convToOutputCharset($objp->$alias);
$typefield=isset($array_types[$code])?$array_types[$code]:'';
// Translation newvalue
if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
{

View File

@ -68,7 +68,8 @@ $conffiletoshow = "htdocs/conf/conf.php";
// Include configuration
$result=@include_once $conffile;
$result=include_once $conffile;
if (! $result && ! empty($_SERVER["GATEWAY_INTERFACE"])) // If install not done and we are in a web session
{
header("Location: install/index.php");
@ -233,6 +234,7 @@ if (! file_exists(DOL_DOCUMENT_ROOT ."/core/lib/functions.lib.php"))
print "Please run dolibarr setup by calling page <b>/install</b>.<br>\n";
exit;
}
// Included by default
include_once DOL_DOCUMENT_ROOT .'/core/lib/functions.lib.php';
@ -251,4 +253,4 @@ if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_d
else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
}
?>
?>

View File

@ -177,7 +177,6 @@ class Holiday extends CommonObject
$sql = "SELECT";
$sql.= " cp.rowid,";
$sql.= " cp.fk_user,";
$sql.= " cp.date_create,";
$sql.= " cp.description,";
@ -192,8 +191,9 @@ class Holiday extends CommonObject
$sql.= " cp.fk_user_refuse,";
$sql.= " cp.date_cancel,";
$sql.= " cp.fk_user_cancel,";
$sql.= " cp.detail_refuse";
$sql.= " cp.detail_refuse,";
$sql.= " cp.note,";
$sql.= " cp.note_public";
$sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp";
$sql.= " WHERE cp.rowid = ".$id;
@ -223,6 +223,8 @@ class Holiday extends CommonObject
$this->date_cancel = $this->db->jdate($obj->date_cancel);
$this->fk_user_cancel = $obj->fk_user_cancel;
$this->detail_refuse = $obj->detail_refuse;
$this->note = $obj->note;
$this->note_public = $obj->note_public;
}
$this->db->free($resql);

View File

@ -123,3 +123,5 @@ ALTER TABLE llx_facturedet MODIFY COLUMN localtax2_type varchar(10) NOT NULL DEF
ALTER TABLE llx_propaldet MODIFY COLUMN localtax1_type varchar(10) NOT NULL DEFAULT '0';
ALTER TABLE llx_propaldet MODIFY COLUMN localtax2_type varchar(10) NOT NULL DEFAULT '0';
ALTER TABLE llx_holiday ADD COLUMN note text;
ALTER TABLE llx_holiday ADD COLUMN note_public text;

View File

@ -33,6 +33,8 @@ date_refuse DATETIME DEFAULT NULL,
fk_user_refuse integer DEFAULT NULL,
date_cancel DATETIME DEFAULT NULL,
fk_user_cancel integer DEFAULT NULL,
detail_refuse varchar( 250 ) DEFAULT NULL
detail_refuse varchar( 250 ) DEFAULT NULL,
note text,
note_public text
)
ENGINE=innodb;

View File

@ -34,6 +34,7 @@
require_once 'filefunc.inc.php'; // May have been already require by main.inc.php. But may not by scripts.
/*
* Create $conf object
*/
@ -194,7 +195,7 @@ if (! defined('NOREQUIREDB') && ! defined('NOREQUIRESOC'))
require_once DOL_DOCUMENT_ROOT .'/societe/class/societe.class.php';
$mysoc=new Societe($db);
$mysoc->getMysoc($conf);
$mysoc->setMysoc($conf);
// For some countries, we need to invert our address with customer address
if ($mysoc->country_code == 'DE' && ! isset($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $conf->global->MAIN_INVERT_SENDER_RECIPIENT=1;

View File

@ -2479,12 +2479,12 @@ class Societe extends CommonObject
}
/**
* Build and get $mysoc object
* Set properties with value into $conf
*
* @param Conf $conf Conf object (possibility to use another entity)
* @return void
*/
function getMysoc($conf)
function setMysoc($conf)
{
global $langs;

View File

@ -137,18 +137,20 @@ class AllTests
$suite->addTestSuite('CompanyBankAccountTest');
require_once dirname(__FILE__).'/ChargeSocialesTest.php';
$suite->addTestSuite('ChargeSocialesTest');
require_once dirname(__FILE__).'/HolidayTest.php';
$suite->addTestSuite('HolidayTest');
require_once dirname(__FILE__).'/CategorieTest.php';
$suite->addTestSuite('CategorieTest');
require_once dirname(__FILE__).'/WebservicesInvoices.php';
$suite->addTestSuite('WebservicesInvoices');
require_once dirname(__FILE__).'/WebservicesOrders.php';
$suite->addTestSuite('WebservicesOrders');
require_once dirname(__FILE__).'/WebservicesOther.php';
$suite->addTestSuite('WebservicesOther');
require_once dirname(__FILE__).'/WebservicesThirparty.php';
$suite->addTestSuite('WebservicesThirdparty');
require_once dirname(__FILE__).'/WebservicesInvoicesTest.php';
$suite->addTestSuite('WebservicesInvoicesTest');
require_once dirname(__FILE__).'/WebservicesOrdersTest.php';
$suite->addTestSuite('WebservicesOrdersTest');
require_once dirname(__FILE__).'/WebservicesOtherTest.php';
$suite->addTestSuite('WebservicesOtherTest');
require_once dirname(__FILE__).'/WebservicesThirdpartyTest.php';
$suite->addTestSuite('WebservicesThirdpartyTest');
require_once dirname(__FILE__).'/WebservicesUserTest.php';
$suite->addTestSuite('WebservicesUserTest');

View File

@ -30,6 +30,12 @@ require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
require_once dirname(__FILE__).'/../../htdocs/contact/class/contact.class.php';
$langs->load("dict");
if ($langs->defaultlang != 'en_US')
{
print "Error: Default language for company to run tests must be set to en_US or auto. Current is ".$langs->defaultlang."\n";
exit;
}
if (empty($user->id))
{
print "Load permissions for admin user nb 1\n";

View File

@ -123,7 +123,19 @@ class CoreTest extends PHPUnit_Framework_TestCase
*/
public function testDetectURLROOT()
{
// Test for subdir dolibarr (that point to htdocs) in root directory /var/www
global $dolibarr_main_prod;
global $dolibarr_main_url_root;
global $dolibarr_main_data_root;
global $dolibarr_main_document_root;
global $dolibarr_main_data_root_alt;
global $dolibarr_main_document_root_alt;
global $dolibarr_main_db_host;
global $dolibarr_main_db_port;
global $dolibarr_main_db_type;
global $dolibarr_main_db_prefix;
// Test for subdir dolibarr (that point to htdocs) in root directory /var/www
// URL: http://localhost/dolibarrnew/admin/system/phpinfo.php
$_SERVER["HTTPS"]='';
$_SERVER["SERVER_NAME"]='localhost';
@ -185,6 +197,8 @@ class CoreTest extends PHPUnit_Framework_TestCase
//$dolibarr_main_url_root='http://localhost/dolibarralias';
//$dolibarr_main_url_root_alt='http://localhost/dolibarralias/custom2';
// Force to rerun filefunc.inc.php
include dirname(__FILE__).'/../../htdocs/filefunc.inc.php';
print __METHOD__." DOL_MAIN_URL_ROOT=".DOL_MAIN_URL_ROOT."\n";

View File

@ -215,39 +215,9 @@ class HolidayTest extends PHPUnit_Framework_TestCase
$this->assertLessThan($result, 0, 'Holiday::fetch error');
print __METHOD__." old=".$localobject->note." new=".$newobject->note."\n";
$this->assertEquals($localobject->note, $newobject->note);
$this->assertEquals($localobject->note, $newobject->note,'Holiday::update_note error compare note');
//print __METHOD__." old=".$localobject->note_public." new=".$newobject->note_public."\n";
//$this->assertEquals($localobject->note_public, $newobject->note_public);
print __METHOD__." old=".$localobject->lastname." new=".$newobject->lastname."\n";
$this->assertEquals($localobject->lastname, $newobject->lastname);
print __METHOD__." old=".$localobject->firstname." new=".$newobject->firstname."\n";
$this->assertEquals($localobject->firstname, $newobject->firstname);
print __METHOD__." old=".$localobject->address." new=".$newobject->address."\n";
$this->assertEquals($localobject->address, $newobject->address);
print __METHOD__." old=".$localobject->zip." new=".$newobject->zip."\n";
$this->assertEquals($localobject->zip, $newobject->zip);
print __METHOD__." old=".$localobject->town." new=".$newobject->town."\n";
$this->assertEquals($localobject->town, $newobject->town);
print __METHOD__." old=".$localobject->country_id." new=".$newobject->country_id."\n";
$this->assertEquals($localobject->country_id, $newobject->country_id);
print __METHOD__." old=BE new=".$newobject->country_code."\n";
$this->assertEquals('BE', $newobject->country_code);
//print __METHOD__." old=".$localobject->status." new=".$newobject->status."\n";
//$this->assertEquals($localobject->status, $newobject->status);
print __METHOD__." old=".$localobject->phone_pro." new=".$newobject->phone_pro."\n";
$this->assertEquals($localobject->phone_pro, $newobject->phone_pro);
print __METHOD__." old=".$localobject->phone_pro." new=".$newobject->phone_pro."\n";
$this->assertEquals($localobject->phone_perso, $newobject->phone_perso);
print __METHOD__." old=".$localobject->phone_mobile." new=".$newobject->phone_mobile."\n";
$this->assertEquals($localobject->phone_mobile, $newobject->phone_mobile);
print __METHOD__." old=".$localobject->fax." new=".$newobject->fax."\n";
$this->assertEquals($localobject->fax, $newobject->fax);
print __METHOD__." old=".$localobject->email." new=".$newobject->email."\n";
$this->assertEquals($localobject->email, $newobject->email);
print __METHOD__." old=".$localobject->jabberid." new=".$newobject->jabberid."\n";
$this->assertEquals($localobject->jabberid, $newobject->jabberid);
print __METHOD__." old=".$localobject->default_lang." new=".$newobject->default_lang."\n";
$this->assertEquals($localobject->default_lang, $newobject->default_lang);
return $localobject;
}
@ -270,7 +240,7 @@ class HolidayTest extends PHPUnit_Framework_TestCase
$db=$this->savdb;
//$localobject->fetch($localobject->id);
/*
$result=$localobject->getNomUrl(1);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
@ -284,7 +254,7 @@ class HolidayTest extends PHPUnit_Framework_TestCase
print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n";
$this->assertNotEquals($localobject->date_creation, '');
*/
return $localobject->id;
}

View File

@ -17,7 +17,7 @@
*/
/**
* \file test/phpunit/WebservicesTest.php
* \file test/phpunit/WebservicesInvoicesTest.php
* \ingroup test
* \brief PHPUnit test
* \remarks To run this script as CLI: phpunit filename.php

View File

@ -17,7 +17,7 @@
*/
/**
* \file test/phpunit/WebservicesTest.php
* \file test/phpunit/WebservicesOrdersTest.php
* \ingroup test
* \brief PHPUnit test
* \remarks To run this script as CLI: phpunit filename.php

View File

@ -17,7 +17,7 @@
*/
/**
* \file test/phpunit/WebservicesTest.php
* \file test/phpunit/WebservicesOtherTest.php
* \ingroup test
* \brief PHPUnit test
* \remarks To run this script as CLI: phpunit filename.php

View File

@ -17,7 +17,7 @@
*/
/**
* \file test/phpunit/WebservicesTest.php
* \file test/phpunit/WebservicesThirdpartyTest.php
* \ingroup test
* \brief PHPUnit test
* \remarks To run this script as CLI: phpunit filename.php

View File

@ -17,7 +17,7 @@
*/
/**
* \file test/phpunit/WebservicesTest.php
* \file test/phpunit/WebservicesUserTest.php
* \ingroup test
* \brief PHPUnit test
* \remarks To run this script as CLI: phpunit filename.php

View File

@ -1,57 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE phpunit SYSTEM "phpunit.dtd" >
<phpunit
backupGlobals="true"
backupStaticAttributes="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
colors="true"
processIsolation="false"
stopOnFailure="true"
syntaxCheck="true">
<php>
<ini name="max_execution_time" value="600"/>
<ini name="max_input_time" value="600"/>
</php>
<filter>
<blacklist>
<directory suffix=".php">../../build/</directory>
<directory suffix=".php">../../dev/</directory>
<directory suffix=".php">../../doc/</directory>
<directory suffix=".php">../../test/</directory>
<directory suffix=".php">../../htdocs/core/menus/smartphone/</directory>
<directory suffix=".php">../../htdocs/products/canvas/</directory>
<directory suffix=".php">../../htdocs/contact/canvas/</directory>
<directory suffix=".php">../../htdocs/societe/canvas/</directory>
<directory suffix=".php">../../htdocs/includes/</directory>
</blacklist>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".class.php">../../htdocs/</directory>
<directory suffix=".lib.php">../../htdocs/</directory>
<directory suffix=".inc.php">../../htdocs/</directory>
<directory suffix=".modules.php">../../htdocs/</directory>
<file>../../htdocs/core/modules/facture/modules_facture.php</file>
<file>../../htdocs/core/modules/commande/modules_commande.php</file>
<file>../../htdocs/core/modules/propale/modules_propale.php</file>
<file>../../htdocs/core/modules/project/modules_project.php</file>
<file>../../htdocs/core/modules/fichinter/modules_fichinter.php</file>
<exclude>
<directory suffix=".php">../../build/</directory>
<directory suffix=".php">../../dev/</directory>
<directory suffix=".php">../../doc/</directory>
<directory suffix=".php">../../test/</directory>
<directory suffix=".php">../../htdocs/core/menus/smartphone</directory>
<directory suffix=".php">../../htdocs/products/canvas/</directory>
<directory suffix=".php">../../htdocs/contact/canvas/</directory>
<directory suffix=".php">../../htdocs/societe/canvas/</directory>
<directory suffix=".php">../../htdocs/includes/</directory>
<file>../../htdocs/boutique/osc_master.inc.php</file>
<file>../../htdocs/compta/bank/pre.inc.php</file>
<file>../../htdocs/compta/paiement/cheque/pre.inc.php</file>
<file>../../htdocs/holiday/common.inc.php</file>
<file>../../htdocs/ftp/pre.inc.php</file>
</exclude>
</whitelist>
</filter>
</phpunit>

View File

@ -20,7 +20,6 @@
<directory suffix=".php">../../dev/</directory>
<directory suffix=".php">../../doc/</directory>
<directory suffix=".php">../../test/</directory>
<directory suffix=".php">../../htdocs/core/menus/smartphone/</directory>
<directory suffix=".php">../../htdocs/custom/</directory>
<directory suffix=".php">../../htdocs/products/canvas/</directory>
<directory suffix=".php">../../htdocs/contact/canvas/</directory>
@ -42,7 +41,6 @@
<directory suffix=".php">../../dev/</directory>
<directory suffix=".php">../../doc/</directory>
<directory suffix=".php">../../test/</directory>
<directory suffix=".php">../../htdocs/core/menus/smartphone</directory>
<directory suffix=".php">../../htdocs/custom/</directory>
<directory suffix=".php">../../htdocs/products/canvas/</directory>
<directory suffix=".php">../../htdocs/contact/canvas/</directory>