forked from Wavyzz/dolibarr
Qual: Improve test messages to help locate errors + php-cs-fixer on tests (#28272)
* Qual: Apply php-cs-fixer before changes # Qual: Apply php-cs-fixer before changes Apply php-cs-fixer before changes to make real changes stand out in next commit. * Qual: Improve test messages to help locate errors. # Qual: Improve test messages to help locate errors. Included a description of the test in the failing assertions to help locate the error. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: Update spelling exception # Qual: Update spelling exception Formatting the code requires an update in the spelling exception list. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out. * Qual: php-cs-fixer on phpunit test file # Qual: php-cs-fixer on phpunit test file Apply php-cs-fixer on phpunit test files so that future manual changes stand out.
This commit is contained in:
@@ -152,8 +152,8 @@
|
||||
$sql = "SELECT p.rowid, p.fk_statut as status, p.fk_opp_status, p.datee as datee";
|
||||
$sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM ".$this->db->prefix()."links";
|
||||
$sql = 'SELECT c.rowid, date_creation as datec, tms as datem, date_valid as date_validation, date_approve as datea, date_approve2 as datea2,';
|
||||
$test = "<IMG SRC=\"jav
ascript:alert('XSS');\">"; // Same
|
||||
$test = '/javas:cript/google.com';
|
||||
$test="<IMG SRC=\"jav
ascript:alert('XSS');\">"; // Same
|
||||
$this->periode = $this->date_creation + 3600 * 24 * 30;
|
||||
$title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Referers');
|
||||
$title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Referers');
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -75,12 +75,12 @@ class AccountingAccountTest extends CommonClassTest
|
||||
public function testAccountingAccountCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new AccountingAccount($db);
|
||||
$localobject = new AccountingAccount($db);
|
||||
$localobject->fk_pcg_version = 'PCG99-ABREGE';
|
||||
$localobject->account_category = 0;
|
||||
$localobject->pcg_type = 'XXXXX';
|
||||
@@ -89,7 +89,7 @@ class AccountingAccountTest extends CommonClassTest
|
||||
$localobject->account_parent = 0;
|
||||
$localobject->label = 'Account specimen';
|
||||
$localobject->active = 0;
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -109,13 +109,13 @@ class AccountingAccountTest extends CommonClassTest
|
||||
public function testAccountingAccountFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new AccountingAccount($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new AccountingAccount($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -135,13 +135,13 @@ class AccountingAccountTest extends CommonClassTest
|
||||
public function testAccountingAccountUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->label='New label';
|
||||
$result=$localobject->update($user);
|
||||
$localobject->label = 'New label';
|
||||
$result = $localobject->update($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -161,14 +161,14 @@ class AccountingAccountTest extends CommonClassTest
|
||||
public function testAccountingAccountDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new AccountingAccount($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new AccountingAccount($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -75,14 +75,14 @@ class ActionCommTest extends CommonClassTest
|
||||
public function testActionCommCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
$localobject=new ActionComm($db);
|
||||
$localobject = new ActionComm($db);
|
||||
|
||||
$localobject->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
|
||||
$localobject->code = 'AC_PHPUNITTEST';
|
||||
@@ -128,13 +128,13 @@ class ActionCommTest extends CommonClassTest
|
||||
public function testActionCommFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new ActionComm($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new ActionComm($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
@@ -153,13 +153,13 @@ class ActionCommTest extends CommonClassTest
|
||||
public function testActionCommUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->label='New label';
|
||||
$result=$localobject->update($user);
|
||||
$localobject->label = 'New label';
|
||||
$result = $localobject->update($user);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
@@ -178,14 +178,14 @@ class ActionCommTest extends CommonClassTest
|
||||
public function testActionCommDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new ActionComm($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new ActionComm($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -38,7 +38,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -85,19 +85,19 @@ class AdherentTest extends CommonClassTest
|
||||
public function testAdherentTypeCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new AdherentType($db);
|
||||
$localobject->statut=1;
|
||||
$localobject->label='Adherent type test';
|
||||
$localobject->subscription=1;
|
||||
$localobject->amount=0;
|
||||
$localobject->vote=1;
|
||||
$localobject->company='Old company label';
|
||||
$result=$localobject->create($user);
|
||||
$localobject = new AdherentType($db);
|
||||
$localobject->statut = 1;
|
||||
$localobject->label = 'Adherent type test';
|
||||
$localobject->subscription = 1;
|
||||
$localobject->amount = 0;
|
||||
$localobject->vote = 1;
|
||||
$localobject->company = 'Old company label';
|
||||
$result = $localobject->create($user);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -116,15 +116,15 @@ class AdherentTest extends CommonClassTest
|
||||
public function testAdherentCreate($fk_adherent_type)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Adherent($db);
|
||||
$localobject = new Adherent($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->typeid=$fk_adherent_type;
|
||||
$result=$localobject->create($user);
|
||||
$localobject->typeid = $fk_adherent_type;
|
||||
$result = $localobject->create($user);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
if ($result < 0) {
|
||||
print $localobject->error;
|
||||
@@ -146,13 +146,13 @@ class AdherentTest extends CommonClassTest
|
||||
public function testAdherentFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Adherent($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Adherent($db);
|
||||
$result = $localobject->fetch($id);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
@@ -170,10 +170,10 @@ class AdherentTest extends CommonClassTest
|
||||
public function testAdherentFetchLogin(Adherent $localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$newobject = new Adherent($db);
|
||||
$result = $newobject->fetch_login($localobject->login);
|
||||
@@ -195,44 +195,44 @@ class AdherentTest extends CommonClassTest
|
||||
public function testAdherentUpdate(Adherent $localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$timestamp = dol_now();
|
||||
|
||||
$localobject->civility_id = 0;
|
||||
$localobject->login='newlogin';
|
||||
$localobject->company='New company label';
|
||||
$localobject->note_public='New note public after update';
|
||||
$localobject->note_private='New note private after update';
|
||||
$localobject->lastname='New name';
|
||||
$localobject->firstname='New firstname';
|
||||
$localobject->gender='man';
|
||||
$localobject->address='New address';
|
||||
$localobject->zip='New zip';
|
||||
$localobject->town='New town';
|
||||
$localobject->country_id=2;
|
||||
$localobject->statut=0;
|
||||
$localobject->morphy=0;
|
||||
$localobject->phone='New tel pro';
|
||||
$localobject->phone_perso='New tel perso';
|
||||
$localobject->phone_mobile='New tel mobile';
|
||||
$localobject->email='newemail@newemail.com';
|
||||
$localobject->birth=$timestamp;
|
||||
$result=$localobject->update($user);
|
||||
$localobject->login = 'newlogin';
|
||||
$localobject->company = 'New company label';
|
||||
$localobject->note_public = 'New note public after update';
|
||||
$localobject->note_private = 'New note private after update';
|
||||
$localobject->lastname = 'New name';
|
||||
$localobject->firstname = 'New firstname';
|
||||
$localobject->gender = 'man';
|
||||
$localobject->address = 'New address';
|
||||
$localobject->zip = 'New zip';
|
||||
$localobject->town = 'New town';
|
||||
$localobject->country_id = 2;
|
||||
$localobject->statut = 0;
|
||||
$localobject->morphy = 0;
|
||||
$localobject->phone = 'New tel pro';
|
||||
$localobject->phone_perso = 'New tel perso';
|
||||
$localobject->phone_mobile = 'New tel mobile';
|
||||
$localobject->email = 'newemail@newemail.com';
|
||||
$localobject->birth = $timestamp;
|
||||
$result = $localobject->update($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
$result=$localobject->update_note($localobject->note_private, '_private');
|
||||
$result = $localobject->update_note($localobject->note_private, '_private');
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
$result=$localobject->update_note($localobject->note_public, '_public');
|
||||
$result = $localobject->update_note($localobject->note_public, '_public');
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
$newobject=new Adherent($db);
|
||||
$result=$newobject->fetch($localobject->id);
|
||||
$newobject = new Adherent($db);
|
||||
$result = $newobject->fetch($localobject->id);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -274,10 +274,10 @@ class AdherentTest extends CommonClassTest
|
||||
public function testAdherentMakeSubstitution(Adherent $localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$conf->global->MAIN_FIRSTNAME_NAME_POSITION = 0; // Force setup for firstname+lastname
|
||||
|
||||
@@ -308,10 +308,10 @@ class AdherentTest extends CommonClassTest
|
||||
public function testAdherentSetUserId(Adherent $localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
//We associate member with user
|
||||
$result = $localobject->setUserId($user->id);
|
||||
@@ -350,10 +350,10 @@ class AdherentTest extends CommonClassTest
|
||||
public function testAdherentSetThirdPartyId(Adherent $localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
//Create a Third Party
|
||||
$thirdparty = new Societe($db);
|
||||
@@ -399,12 +399,12 @@ class AdherentTest extends CommonClassTest
|
||||
public function testAdherentValidate(Adherent $localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->validate($user);
|
||||
$result = $localobject->validate($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -423,10 +423,10 @@ class AdherentTest extends CommonClassTest
|
||||
public function testAdherentOther(Adherent $localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
/*$result=$localobject->setstatus(0);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
@@ -452,10 +452,10 @@ class AdherentTest extends CommonClassTest
|
||||
public function testAdherentResiliate(Adherent $localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
//Let's resilie un adherent
|
||||
$result = $localobject->resiliate($user);
|
||||
@@ -489,12 +489,12 @@ class AdherentTest extends CommonClassTest
|
||||
public function testAdherentDelete($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->delete($localobject->id, $user);
|
||||
$result = $localobject->delete($localobject->id, $user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -514,14 +514,14 @@ class AdherentTest extends CommonClassTest
|
||||
public function testAdherentTypeDelete($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobjectat=new AdherentType($db);
|
||||
$result=$localobjectat->fetch($localobject->typeid);
|
||||
$result=$localobjectat->delete($user);
|
||||
$localobjectat = new AdherentType($db);
|
||||
$result = $localobjectat->fetch($localobject->typeid);
|
||||
$result = $localobjectat->delete($user);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -59,21 +59,21 @@ class AdminLibTest extends CommonClassTest
|
||||
public function testVersionCompare()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=versioncompare(array(3,1,-4), array(3,1,1));
|
||||
$result = versioncompare(array(3,1,-4), array(3,1,1));
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(-3, $result);
|
||||
$result=versioncompare(array(3,1,0), array(3,1,1));
|
||||
$result = versioncompare(array(3,1,0), array(3,1,1));
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(-3, $result);
|
||||
$result=versioncompare(array(3,1,0), array(3,2,0));
|
||||
$result = versioncompare(array(3,1,0), array(3,2,0));
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(-2, $result);
|
||||
$result=versioncompare(array(3,1,0), array(3,1,0));
|
||||
$result = versioncompare(array(3,1,0), array(3,1,0));
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(0, $result);
|
||||
|
||||
@@ -91,7 +91,7 @@ class AdminLibTest extends CommonClassTest
|
||||
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/modExpenseReport.class.php';
|
||||
print "Enable module modExpenseReport";
|
||||
$moduledescriptor=new modExpenseReport($db);
|
||||
$moduledescriptor = new modExpenseReport($db);
|
||||
|
||||
$result = $moduledescriptor->remove();
|
||||
|
||||
@@ -102,7 +102,7 @@ class AdminLibTest extends CommonClassTest
|
||||
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/modApi.class.php';
|
||||
print "Enable module modAPI";
|
||||
$moduledescriptor=new modApi($db);
|
||||
$moduledescriptor = new modApi($db);
|
||||
|
||||
$result = $moduledescriptor->remove();
|
||||
|
||||
|
||||
@@ -53,8 +53,8 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_UMASK='666';
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
$conf->global->MAIN_UMASK = '666';
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -85,13 +85,13 @@ class AssetModelTest extends CommonClassTest
|
||||
public function testAssetModelFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new AssetModel($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new AssetModel($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
@@ -114,7 +114,7 @@ class AssetModelTest extends CommonClassTest
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->note_private='New note private after update';
|
||||
$localobject->note_private = 'New note private after update';
|
||||
$result = $localobject->update($user);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -35,7 +35,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
$langs->load("main");
|
||||
|
||||
@@ -57,14 +57,14 @@ class BOMTest extends CommonClassTest
|
||||
public function testBOMCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new BOM($db);
|
||||
$localobject = new BOM($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -84,14 +84,14 @@ class BOMTest extends CommonClassTest
|
||||
public function testBOMDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new BOM($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new BOM($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -37,7 +37,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
$langs->load("main");
|
||||
|
||||
@@ -59,15 +59,15 @@ class BankAccountTest extends CommonClassTest
|
||||
public function testBankAccountCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject = new Account($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->date_solde = dol_now();
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -87,13 +87,13 @@ class BankAccountTest extends CommonClassTest
|
||||
public function testBankAccountFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Account($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Account($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -113,10 +113,10 @@ class BankAccountTest extends CommonClassTest
|
||||
public function testBankAccountOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
/*$result=$localobject->setstatus(0);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
@@ -135,7 +135,7 @@ class BankAccountTest extends CommonClassTest
|
||||
$this->assertTrue($result);
|
||||
|
||||
// Test checkIbanForAccount for CI account
|
||||
$localobject2=new Account($db);
|
||||
$localobject2 = new Account($db);
|
||||
$localobject2->country = 'CI';
|
||||
$localobject2->iban = 'CI77A12312341234123412341234';
|
||||
$result = checkIbanForAccount($localobject2);
|
||||
@@ -157,14 +157,14 @@ class BankAccountTest extends CommonClassTest
|
||||
public function testBankAccountDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Account($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new Account($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
$langs->load("main");
|
||||
|
||||
@@ -58,10 +58,10 @@ class BarcodeTest extends CommonClassTest
|
||||
public function testBarcodeZATCAEncode()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$company = new Societe($db);
|
||||
$company->name = 'Specimen company';
|
||||
@@ -92,10 +92,10 @@ class BarcodeTest extends CommonClassTest
|
||||
public function testBarcodeZATCADecode()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
//$string_zatca_base64 = "AQZSYWZlZXECDTEyMzQ1Njc4OVQxMjUDFDIwMjEtMDctMTJUMTQ6MjU6MDlaBAM3ODYFAjI1";
|
||||
$string_zatca_base64 = "ARBTcGVjaW1lbiBjb21wYW55AgkxMjM0NTY3ODkDFDIwMjAtMDEtMDFUMDk6MzQ6NTZaBAMxMjAFAjIw";
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
$langs->load("main");
|
||||
|
||||
@@ -58,10 +58,10 @@ class BonPrelevementTest extends CommonClassTest
|
||||
public function testBonPrelevementCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// TODO
|
||||
// Create invoice
|
||||
@@ -74,9 +74,9 @@ class BonPrelevementTest extends CommonClassTest
|
||||
|
||||
|
||||
// Create withdraw record and generate SEPA file
|
||||
$localobject=new BonPrelevement($db);
|
||||
$localobject = new BonPrelevement($db);
|
||||
//$localobject->date_solde=dol_now();
|
||||
$result=$localobject->Create(0, 0, 'simu');
|
||||
$result = $localobject->Create(0, 0, 'simu');
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, 0);
|
||||
|
||||
@@ -66,7 +66,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -132,19 +132,19 @@ class BuildDocTest extends CommonClassTest
|
||||
public function testFactureBuild()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$conf->facture->dir_output.='/temp';
|
||||
$conf->facture->dir_output .= '/temp';
|
||||
|
||||
$localobjectcom=new Commande($db);
|
||||
$localobjectcom = new Commande($db);
|
||||
$localobjectcom->initAsSpecimen();
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->createFromOrder($localobjectcom, $user);
|
||||
$localobject->date_lim_reglement = dol_now() + 3600 * 24 *30;
|
||||
$localobject->date_lim_reglement = dol_now() + 3600 * 24 * 30;
|
||||
$localobject->status = Facture::STATUS_DRAFT;
|
||||
|
||||
// To be sure we are not using the Swiss QR Code addition
|
||||
@@ -155,7 +155,7 @@ class BuildDocTest extends CommonClassTest
|
||||
$conf->global->MAIN_DISABLE_TCPDI = 1;
|
||||
|
||||
// Crabe (english)
|
||||
$localobject->model_pdf='crabe';
|
||||
$localobject->model_pdf = 'crabe';
|
||||
$result = $localobject->generateDocument($localobject->model_pdf, $langs);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result." for generation from crabe\n";
|
||||
@@ -164,55 +164,55 @@ class BuildDocTest extends CommonClassTest
|
||||
$conf->global->MAIN_DISABLE_TCPDI = 0;
|
||||
|
||||
// Crabe (english)
|
||||
$localobject->model_pdf='crabe';
|
||||
$localobject->model_pdf = 'crabe';
|
||||
$result = $localobject->generateDocument($localobject->model_pdf, $langs);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result." for generation from crabe with MAIN_DISABLE_TCPDI and a watermark\n";
|
||||
|
||||
// Crabe (japanese)
|
||||
$newlangs1=new Translate("", $conf);
|
||||
$newlangs1 = new Translate("", $conf);
|
||||
$newlangs1->setDefaultLang('ja_JP');
|
||||
$localobject->model_pdf='crabe';
|
||||
$localobject->model_pdf = 'crabe';
|
||||
$result = $localobject->generateDocument($localobject->model_pdf, $newlangs1);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
// Crabe (saudiarabia)
|
||||
$newlangs2a=new Translate("", $conf);
|
||||
$newlangs2a = new Translate("", $conf);
|
||||
$newlangs2a->setDefaultLang('sa_SA');
|
||||
$localobject->model_pdf='crabe';
|
||||
$localobject->model_pdf = 'crabe';
|
||||
$result = $localobject->generateDocument($localobject->model_pdf, $newlangs2a);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
// Crabe (english_saudiarabia)
|
||||
$newlangs2b=new Translate("", $conf);
|
||||
$newlangs2b = new Translate("", $conf);
|
||||
$newlangs2b->setDefaultLang('en_SA');
|
||||
$localobject->model_pdf='crabe';
|
||||
$localobject->model_pdf = 'crabe';
|
||||
$result = $localobject->generateDocument($localobject->model_pdf, $newlangs2b);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
// Crabe (greek)
|
||||
$newlangs3=new Translate("", $conf);
|
||||
$newlangs3 = new Translate("", $conf);
|
||||
$newlangs3->setDefaultLang('el_GR');
|
||||
$localobject->model_pdf='crabe';
|
||||
$localobject->model_pdf = 'crabe';
|
||||
$result = $localobject->generateDocument($localobject->model_pdf, $newlangs3);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
// Crabe (chinese)
|
||||
$newlangs4=new Translate("", $conf);
|
||||
$newlangs4 = new Translate("", $conf);
|
||||
$newlangs4->setDefaultLang('zh_CN');
|
||||
$localobject->model_pdf='crabe';
|
||||
$localobject->model_pdf = 'crabe';
|
||||
$result = $localobject->generateDocument($localobject->model_pdf, $newlangs4);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
// Crabe (russian)
|
||||
$newlangs5=new Translate("", $conf);
|
||||
$newlangs5 = new Translate("", $conf);
|
||||
$newlangs5->setDefaultLang('ru_RU');
|
||||
$localobject->model_pdf='crabe';
|
||||
$localobject->model_pdf = 'crabe';
|
||||
$result = $localobject->generateDocument($localobject->model_pdf, $newlangs5);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -228,17 +228,17 @@ class BuildDocTest extends CommonClassTest
|
||||
public function testFactureFournisseurBuild()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$conf->fournisseur->facture->dir_output.='/temp';
|
||||
$localobject=new FactureFournisseur($db);
|
||||
$conf->fournisseur->facture->dir_output .= '/temp';
|
||||
$localobject = new FactureFournisseur($db);
|
||||
$localobject->initAsSpecimen();
|
||||
|
||||
// Canelle
|
||||
$localobject->model_pdf='canelle';
|
||||
$localobject->model_pdf = 'canelle';
|
||||
$result = $localobject->generateDocument($localobject->model_pdf, $langs);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -255,17 +255,17 @@ class BuildDocTest extends CommonClassTest
|
||||
public function testCommandeBuild()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$conf->commande->dir_output.='/temp';
|
||||
$localobject=new Commande($db);
|
||||
$conf->commande->dir_output .= '/temp';
|
||||
$localobject = new Commande($db);
|
||||
$localobject->initAsSpecimen();
|
||||
|
||||
// Einstein
|
||||
$localobject->model_pdf='einstein';
|
||||
$localobject->model_pdf = 'einstein';
|
||||
$result = $localobject->generateDocument($localobject->model_pdf, $langs);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -283,18 +283,18 @@ class BuildDocTest extends CommonClassTest
|
||||
public function testCommandeFournisseurBuild()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$conf->fournisseur->commande->dir_output.='/temp';
|
||||
$localobject=new CommandeFournisseur($db);
|
||||
$conf->fournisseur->commande->dir_output .= '/temp';
|
||||
$localobject = new CommandeFournisseur($db);
|
||||
$localobject->initAsSpecimen();
|
||||
|
||||
// Muscadet
|
||||
$localobject->model_pdf='muscadet';
|
||||
$result= $localobject->generateDocument($localobject->model_pdf, $langs);
|
||||
$localobject->model_pdf = 'muscadet';
|
||||
$result = $localobject->generateDocument($localobject->model_pdf, $langs);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -310,17 +310,17 @@ class BuildDocTest extends CommonClassTest
|
||||
public function testPropalBuild()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$conf->propal->dir_output.='/temp';
|
||||
$localobject=new Propal($db);
|
||||
$conf->propal->dir_output .= '/temp';
|
||||
$localobject = new Propal($db);
|
||||
$localobject->initAsSpecimen();
|
||||
|
||||
// Azur
|
||||
$localobject->model_pdf='azur';
|
||||
$localobject->model_pdf = 'azur';
|
||||
$result = $localobject->generateDocument($localobject->model_pdf, $langs);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -337,16 +337,16 @@ class BuildDocTest extends CommonClassTest
|
||||
public function testProjectBuild()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf->project->dir_output.='/temp';
|
||||
$localobject=new Project($db);
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
$conf->project->dir_output .= '/temp';
|
||||
$localobject = new Project($db);
|
||||
$localobject->initAsSpecimen();
|
||||
|
||||
// Baleine
|
||||
$localobject->model_pdf='baleine';
|
||||
$localobject->model_pdf = 'baleine';
|
||||
$result = $localobject->generateDocument($localobject->model_pdf, $langs);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -363,18 +363,18 @@ class BuildDocTest extends CommonClassTest
|
||||
public function testFichinterBuild()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$conf->ficheinter->dir_output.='/temp';
|
||||
$localobject=new Fichinter($db);
|
||||
$conf->ficheinter->dir_output .= '/temp';
|
||||
$localobject = new Fichinter($db);
|
||||
$localobject->initAsSpecimen();
|
||||
|
||||
// Soleil
|
||||
$localobject->model_pdf='soleil';
|
||||
$result=fichinter_create($db, $localobject, $localobject->model_pdf, $langs);
|
||||
$localobject->model_pdf = 'soleil';
|
||||
$result = fichinter_create($db, $localobject, $localobject->model_pdf, $langs);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -390,25 +390,25 @@ class BuildDocTest extends CommonClassTest
|
||||
public function testExpeditionBuild()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$conf->expedition->dir_output.='/temp';
|
||||
$localobject=new Expedition($db);
|
||||
$conf->expedition->dir_output .= '/temp';
|
||||
$localobject = new Expedition($db);
|
||||
$localobject->initAsSpecimen();
|
||||
|
||||
// Merou
|
||||
$localobject->model_pdf='merou';
|
||||
$result= $localobject->generateDocument($localobject->model_pdf, $langs);
|
||||
$localobject->model_pdf = 'merou';
|
||||
$result = $localobject->generateDocument($localobject->model_pdf, $langs);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
// Rouget
|
||||
$localobject->model_pdf='rouget';
|
||||
$result= $localobject->generateDocument($localobject->model_pdf, $langs);
|
||||
$localobject->model_pdf = 'rouget';
|
||||
$result = $localobject->generateDocument($localobject->model_pdf, $langs);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
@@ -163,28 +163,29 @@ class CMailFileTest extends CommonClassTest
|
||||
$this->assertEquals($result, 2);
|
||||
|
||||
|
||||
foreach ($localobject->html_images as $i => $val)
|
||||
if ($localobject->html_images[$i]) {
|
||||
if (preg_match('/img250x20\.png/i', $localobject->html_images[$i]['fullpath'])) {
|
||||
print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n";
|
||||
$this->assertEquals($localobject->html_images[$i]['content_type'], 'image/png');
|
||||
foreach ($localobject->html_images as $i => $val) {
|
||||
if ($localobject->html_images[$i]) {
|
||||
if (preg_match('/img250x20\.png/i', $localobject->html_images[$i]['fullpath'])) {
|
||||
print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n";
|
||||
$this->assertEquals($localobject->html_images[$i]['content_type'], 'image/png');
|
||||
|
||||
print __METHOD__ . " type must be cidfromurl =" . $localobject->html_images[$i]['type'] . "\n";
|
||||
$this->assertEquals($localobject->html_images[$i]['type'], 'cidfromurl');
|
||||
print __METHOD__ . " type must be cidfromurl =" . $localobject->html_images[$i]['type'] . "\n";
|
||||
$this->assertEquals($localobject->html_images[$i]['type'], 'cidfromurl');
|
||||
|
||||
$fileSize = 9744;
|
||||
print __METHOD__ . " File size must be =" . $fileSize . "\n";
|
||||
$this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize);
|
||||
} elseif (preg_match('/\.png/i', $localobject->html_images[$i]['fullpath'])) {
|
||||
print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n";
|
||||
$this->assertEquals($localobject->html_images[$i]['content_type'], 'image/png');
|
||||
$fileSize = 9744;
|
||||
print __METHOD__ . " File size must be =" . $fileSize . "\n";
|
||||
$this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize);
|
||||
} elseif (preg_match('/\.png/i', $localobject->html_images[$i]['fullpath'])) {
|
||||
print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n";
|
||||
$this->assertEquals($localobject->html_images[$i]['content_type'], 'image/png');
|
||||
|
||||
print __METHOD__ . " type must be cidfromdata =" . $localobject->html_images[$i]['type'] . "\n";
|
||||
$this->assertEquals($localobject->html_images[$i]['type'], 'cidfromdata');
|
||||
print __METHOD__ . " type must be cidfromdata =" . $localobject->html_images[$i]['type'] . "\n";
|
||||
$this->assertEquals($localobject->html_images[$i]['type'], 'cidfromdata');
|
||||
|
||||
$fileSize = 85;
|
||||
print __METHOD__ . " File size must be =" . $fileSize . "\n";
|
||||
$this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize);
|
||||
$fileSize = 85;
|
||||
print __METHOD__ . " File size must be =" . $fileSize . "\n";
|
||||
$this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -57,36 +57,36 @@ class CategorieTest extends CommonClassTest
|
||||
public function testCategorieCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
|
||||
// We create a category
|
||||
$localobject=new Categorie($db);
|
||||
$localobject = new Categorie($db);
|
||||
$localobject->initAsSpecimen();
|
||||
|
||||
// Check it does not exist (return 0)
|
||||
$resultCheck=$localobject->already_exists();
|
||||
$resultCheck = $localobject->already_exists();
|
||||
print __METHOD__." resultCheck=".$resultCheck."\n";
|
||||
$this->assertEquals(0, $resultCheck);
|
||||
|
||||
// Create
|
||||
$resultFirstCreate=$localobject->create($user);
|
||||
$resultFirstCreate = $localobject->create($user);
|
||||
print __METHOD__." resultFirstCreate=".$resultFirstCreate."\n";
|
||||
$this->assertGreaterThan(0, $resultFirstCreate);
|
||||
|
||||
// We try to create another one with same ref
|
||||
$localobject2=new Categorie($db);
|
||||
$localobject2 = new Categorie($db);
|
||||
$localobject2->initAsSpecimen();
|
||||
|
||||
// Check it does exist (return 1)
|
||||
$resultCheck=$localobject2->already_exists();
|
||||
$resultCheck = $localobject2->already_exists();
|
||||
print __METHOD__." resultCheck=".$resultCheck."\n";
|
||||
$this->assertGreaterThan(0, $resultCheck);
|
||||
|
||||
$resultSecondCreate=$localobject2->create($user);
|
||||
$resultSecondCreate = $localobject2->create($user);
|
||||
print __METHOD__." result=".$resultSecondCreate."\n";
|
||||
$this->assertEquals(-4, $resultSecondCreate);
|
||||
|
||||
@@ -105,37 +105,37 @@ class CategorieTest extends CommonClassTest
|
||||
public function testCategorieProduct($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobjecttmp=new Categorie($db);
|
||||
$localobjecttmp = new Categorie($db);
|
||||
$localobjecttmp->initAsSpecimen();
|
||||
$localobjecttmp->label='Specimen Category for product';
|
||||
$localobjecttmp->type=0; // product category
|
||||
$catid=$localobjecttmp->create($user);
|
||||
$localobjecttmp->label = 'Specimen Category for product';
|
||||
$localobjecttmp->type = 0; // product category
|
||||
$catid = $localobjecttmp->create($user);
|
||||
|
||||
print __METHOD__." catid=".$catid."\n";
|
||||
$this->assertGreaterThan(0, $catid);
|
||||
|
||||
// Try to create product linked to category
|
||||
$localobject2=new Product($db);
|
||||
$localobject2 = new Product($db);
|
||||
$localobject2->initAsSpecimen();
|
||||
$localobject2->ref.='-CATEG';
|
||||
$localobject2->tva_npr=1;
|
||||
$result=$localobject2->create($user);
|
||||
$localobject2->ref .= '-CATEG';
|
||||
$localobject2->tva_npr = 1;
|
||||
$result = $localobject2->create($user);
|
||||
$cat = new Categorie($db);
|
||||
$cat->id = $catid;
|
||||
$cat->type = 0;
|
||||
$result=$cat->add_type($localobject2, "product");
|
||||
$result = $cat->add_type($localobject2, "product");
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
|
||||
// Get list of categories for product
|
||||
$localcateg=new Categorie($db);
|
||||
$listofcateg=$localcateg->containing($localobject2->id, Categorie::TYPE_PRODUCT, 'label');
|
||||
$localcateg = new Categorie($db);
|
||||
$listofcateg = $localcateg->containing($localobject2->id, Categorie::TYPE_PRODUCT, 'label');
|
||||
$this->assertTrue(in_array('Specimen Category for product', $listofcateg), 'Categ not found linked to product when it should');
|
||||
|
||||
return $id;
|
||||
@@ -153,13 +153,13 @@ class CategorieTest extends CommonClassTest
|
||||
public function testCategorieFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Categorie($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Categorie($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
@@ -178,13 +178,13 @@ class CategorieTest extends CommonClassTest
|
||||
public function testCategorieUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->note_private ='New note after update';
|
||||
$result=$localobject->update($user);
|
||||
$localobject->note_private = 'New note after update';
|
||||
$result = $localobject->update($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
@@ -204,17 +204,17 @@ class CategorieTest extends CommonClassTest
|
||||
public function testCategorieOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$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);
|
||||
*/
|
||||
|
||||
$retarray=$localobject->liste_photos('/');
|
||||
$retarray = $localobject->liste_photos('/');
|
||||
print __METHOD__." retarray size=".count($retarray)."\n";
|
||||
$this->assertTrue(is_array($retarray));
|
||||
|
||||
@@ -233,14 +233,14 @@ class CategorieTest extends CommonClassTest
|
||||
public function testCategorieDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Categorie($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new Categorie($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
@@ -257,13 +257,13 @@ class CategorieTest extends CommonClassTest
|
||||
public function testCategorieStatic()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Categorie($db);
|
||||
$retarray=$localobject->get_full_arbo(3);
|
||||
$localobject = new Categorie($db);
|
||||
$retarray = $localobject->get_full_arbo(3);
|
||||
|
||||
print __METHOD__." retarray size=".count($retarray)."\n";
|
||||
$this->assertTrue(is_array($retarray));
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,14 +56,14 @@ class ChargeSocialesTest extends CommonClassTest
|
||||
public function testChargeSocialesCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new ChargeSociales($db);
|
||||
$localobject = new ChargeSociales($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user, $langs, $conf);
|
||||
$result = $localobject->create($user, $langs, $conf);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -82,13 +82,13 @@ class ChargeSocialesTest extends CommonClassTest
|
||||
public function testChargeSocialesFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new ChargeSociales($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new ChargeSociales($db);
|
||||
$result = $localobject->fetch($id);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -107,12 +107,12 @@ class ChargeSocialesTest extends CommonClassTest
|
||||
public function testChargeSocialesValid($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->setPaid($user);
|
||||
$result = $localobject->setPaid($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -131,16 +131,16 @@ class ChargeSocialesTest extends CommonClassTest
|
||||
public function testChargeSocialesOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->getNomUrl(1);
|
||||
$result = $localobject->getNomUrl(1);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertNotEquals($result, '');
|
||||
|
||||
$result=$localobject->getSommePaiement();
|
||||
$result = $localobject->getSommePaiement();
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThanOrEqual($result, 0);
|
||||
|
||||
@@ -160,14 +160,14 @@ class ChargeSocialesTest extends CommonClassTest
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new ChargeSociales($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new ChargeSociales($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -68,7 +68,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -88,10 +88,10 @@ class CodingPhpTest extends CommonClassTest
|
||||
public function testPHP()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
$filesarray = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, '\.php', null, 'fullname', SORT_ASC, 0, 1, '', 1);
|
||||
@@ -117,7 +117,7 @@ class CodingPhpTest extends CommonClassTest
|
||||
}
|
||||
|
||||
//print 'Check php file '.$file['relativename']."\n";
|
||||
$filecontent=file_get_contents($file['fullname']);
|
||||
$filecontent = file_get_contents($file['fullname']);
|
||||
|
||||
if (preg_match('/\.class\.php/', $file['relativename'])
|
||||
|| preg_match('/boxes\/box_/', $file['relativename'])
|
||||
@@ -136,12 +136,12 @@ class CodingPhpTest extends CommonClassTest
|
||||
'multicurrency.class.php'
|
||||
))) {
|
||||
// Must not find $db->
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
// Check string $db-> inside a class.php file (it should be $this->db-> into such classes)
|
||||
preg_match_all('/'.preg_quote('$db->', '/').'/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
//print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n";
|
||||
@@ -200,12 +200,12 @@ class CodingPhpTest extends CommonClassTest
|
||||
'DoliStorage.php'
|
||||
))) {
|
||||
// Must not found $this->db->
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
// Check string $this->db-> into a non class.php file (it should be $db-> into such classes)
|
||||
preg_match_all('/'.preg_quote('$this->db->', '/').'/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
//print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n";
|
||||
@@ -217,11 +217,11 @@ class CodingPhpTest extends CommonClassTest
|
||||
// Check we don't miss top_httphead() into any ajax pages
|
||||
if (preg_match('/ajax\//', $file['relativename'])) {
|
||||
print "Analyze ajax page ".$file['relativename']."\n";
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/top_httphead/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
if (count($matches) == 0) {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
}
|
||||
//print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n";
|
||||
$this->assertTrue($ok, 'Did not find top_httphead into the ajax page '.$file['relativename']);
|
||||
@@ -231,13 +231,13 @@ class CodingPhpTest extends CommonClassTest
|
||||
// Check if a var_dump has been forgotten
|
||||
if (!preg_match('/test\/phpunit/', $file['fullname'])) {
|
||||
if (! in_array($file['name'], array('class.nusoap_base.php'))) {
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/(.)\s*var_dump\(/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
//var_dump($matches);
|
||||
foreach ($matches as $key => $val) {
|
||||
if ($val[1] != '/' && $val[1] != '*') {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -249,11 +249,11 @@ class CodingPhpTest extends CommonClassTest
|
||||
}
|
||||
|
||||
// Check get_class followed by __METHOD__
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/'.preg_quote('get_class($this)."::".__METHOD__', '/').'/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
//print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n";
|
||||
@@ -261,12 +261,12 @@ class CodingPhpTest extends CommonClassTest
|
||||
//exit;
|
||||
|
||||
// Check string $this->db->idate without quotes
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/(..)\s*\.\s*\$this->db->idate\(/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
if ($val[1] != '\'"' && $val[1] != '\'\'') {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
//if ($reg[0] != 'db') $ok=false;
|
||||
@@ -278,8 +278,8 @@ class CodingPhpTest extends CommonClassTest
|
||||
|
||||
// Check sql string DELETE|OR|AND|WHERE|INSERT ... yyy = ".$xxx
|
||||
// with xxx that is not 'thi' (for $this->db->sanitize) and 'db-' (for $db->sanitize). It means we forget a ' if string, or an (int) if int, when forging sql request.
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/(DELETE|OR|AND|WHERE|INSERT)\s.*([^\s][^\s][^\s])\s*=\s*(\'|")\s*\.\s*\$(...)/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
if ($val[2] == 'ity' && $val[4] == 'con') { // exclude entity = ".$conf->entity
|
||||
@@ -292,7 +292,7 @@ class CodingPhpTest extends CommonClassTest
|
||||
continue;
|
||||
}
|
||||
var_dump($matches);
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
//print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n";
|
||||
@@ -300,13 +300,13 @@ class CodingPhpTest extends CommonClassTest
|
||||
//exit;
|
||||
|
||||
// Check that forged sql string is using ' instead of " as string PHP quotes
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/\$sql \.= \'\s*VALUES.*\$/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
//if ($val[1] != '\'"' && $val[1] != '\'\'') {
|
||||
var_dump($matches);
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
//}
|
||||
//if ($reg[0] != 'db') $ok=false;
|
||||
@@ -316,20 +316,20 @@ class CodingPhpTest extends CommonClassTest
|
||||
//exit;
|
||||
|
||||
// Check that forged sql string is using ' instead of " as string PHP quotes
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/\$sql \.?= \'SELECT.*\$/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
var_dump($matches);
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
$this->assertTrue($ok, 'Found a forged SQL string that mix on same line the use of \' for PHP string and PHP variables into file '.$file['relativename'].' Use " to forge PHP string like this: $sql = "SELECT ".$myvar...');
|
||||
|
||||
// Check sql string VALUES ... , ".$xxx
|
||||
// with xxx that is not 'db-' (for $db->escape). It means we forget a ' if string, or an (int) if int, when forging sql request.
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/(VALUES).*,\s*"\s*\.\s*\$(...)/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
if ($val[1] == 'VALUES' && $val[2] == 'db-') { // exclude $db->escape(
|
||||
@@ -339,7 +339,7 @@ class CodingPhpTest extends CommonClassTest
|
||||
continue;
|
||||
}
|
||||
var_dump($matches);
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
//print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n";
|
||||
@@ -349,12 +349,12 @@ class CodingPhpTest extends CommonClassTest
|
||||
// Check '".$xxx non escaped
|
||||
|
||||
// Check string ='".$this->xxx with xxx that is not 'escape'. It means we forget a db->escape when forging sql request.
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/=\s*\'"\s*\.\s*\$this->(....)/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
if ($val[1] != 'db->' && $val[1] != 'esca') {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -362,12 +362,12 @@ class CodingPhpTest extends CommonClassTest
|
||||
$this->assertTrue($ok, 'Found non escaped string in building of a sql request (case 1) in '.$file['relativename'].' - Bad.');
|
||||
|
||||
// Check string sql|set|WHERE|...'".$yyy->xxx with xxx that is not 'escape', 'idate', .... It means we forget a db->escape when forging sql request.
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/(sql|SET|WHERE|INSERT|VALUES|LIKE).+\s*\'"\s*\.\s*\$(.......)/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
if (! in_array($val[2], array('this->d', 'this->e', 'db->esc', 'dbs->es', 'dbs->id', 'mydb->e', 'dbsessi', 'db->ida', 'escaped', 'exclude', 'include'))) {
|
||||
$ok=false; // This will generate error
|
||||
$ok = false; // This will generate error
|
||||
break;
|
||||
}
|
||||
//if ($reg[0] != 'db') $ok=false;
|
||||
@@ -377,12 +377,12 @@ class CodingPhpTest extends CommonClassTest
|
||||
//exit;
|
||||
|
||||
// Check string sql|set...'.$yyy->xxx with xxx that is not 'escape', 'idate', .... It means we forget a db->escape when forging sql request.
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/(\$sql|SET\s|WHERE\s|INSERT\s|VALUES\s|VALUES\().+\s*\'\s*\.\s*\$(.........)/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
if (! in_array($val[2], array('this->db-', 'db->prefi', 'db->sanit', 'dbs->pref', 'dbs->sani', 'conf->ent', 'key : \'\')', 'key])."\')', 'excludefi', 'regexstri', ''))) {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
var_dump($matches);
|
||||
break;
|
||||
}
|
||||
@@ -395,13 +395,13 @@ class CodingPhpTest extends CommonClassTest
|
||||
// Checks with IN
|
||||
|
||||
// Check string ' IN (".xxx' or ' IN (\'.xxx' with xxx that is not '$this->db->sanitize' and not '$db->sanitize'. It means we forget a db->sanitize when forging sql request.
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/\s+IN\s*\([\'"]\s*\.\s*(.........)/i', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
//var_dump($val);
|
||||
if (!in_array($val[1], array('$db->sani', '$this->db', 'getEntity', 'WON\',\'L', 'self::STA', 'Commande:', 'CommandeF', 'Entrepot:', 'Facture::', 'FactureFo', 'ExpenseRe', 'Societe::', 'Ticket::S'))) {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
//if ($reg[0] != 'db') $ok=false;
|
||||
@@ -411,13 +411,13 @@ class CodingPhpTest extends CommonClassTest
|
||||
//exit;
|
||||
|
||||
// Check string ' IN (\'".xxx' with xxx that is not '$this->db->sanitize' and not '$db->sanitize'. It means we forget a db->sanitize when forging sql request.
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/\s+IN\s*\(\'"\s*\.\s*(.........)/i', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
//var_dump($val);
|
||||
if (!in_array($val[1], array('$db->sani', '$this->db', 'getEntity', 'WON\',\'L', 'self::STA', 'Commande:', 'CommandeF', 'Entrepot:', 'Facture::', 'FactureFo', 'ExpenseRe', 'Societe::', 'Ticket::S'))) {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
//if ($reg[0] != 'db') $ok=false;
|
||||
@@ -427,12 +427,12 @@ class CodingPhpTest extends CommonClassTest
|
||||
//exit;
|
||||
|
||||
// Test that output of $_SERVER\[\'QUERY_STRING\'\] is escaped.
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/(..............)\$_SERVER\[\'QUERY_STRING\'\]/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
if ($val[1] != 'scape_htmltag(' && $val[1] != 'ing_nohtmltag(' && $val[1] != 'dol_escape_js(') {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -440,8 +440,8 @@ class CodingPhpTest extends CommonClassTest
|
||||
|
||||
|
||||
// Check GETPOST(... 'none');
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/GETPOST\s*\(([^\)]+),\s*["\']none["\']/i', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
//var_dump($val);
|
||||
@@ -450,7 +450,7 @@ class CodingPhpTest extends CommonClassTest
|
||||
'"mysqldump"', '"postgresqldump"',
|
||||
"'db_pass_root'", "'db_pass'", '"pass"', '"pass1"', '"pass2"', '"password"', "'password'",
|
||||
'"MAIN_MAIL_SMTPS_PW"', '"MAIN_MAIL_SMTPS_PW_EMAILING"', '"MAIN_MAIL_SMTPS_PW_TICKET"'))) {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
//if ($reg[0] != 'db') $ok=false;
|
||||
@@ -461,24 +461,24 @@ class CodingPhpTest extends CommonClassTest
|
||||
|
||||
|
||||
// Test that first param of print_liste_field_titre is a translation key and not the translated value
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
// Check string ='print_liste_field_titre\(\$langs'.
|
||||
preg_match_all('/print_liste_field_titre\(\$langs/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
$this->assertTrue($ok, 'Found a use of print_liste_field_titre with first parameter that is a translated value instead of just the translation key in file '.$file['relativename'].'. Bad.');
|
||||
|
||||
|
||||
// Test we don't have <br />
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/<br\s+\/>/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
if ($file['name'] != 'functions.lib.php') {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -486,12 +486,12 @@ class CodingPhpTest extends CommonClassTest
|
||||
|
||||
|
||||
// Test we don't have name="token" value="'.$_SESSION['newtoken'], we must use name="token" value="'.newToken() instead.
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/name="token" value="\'\s*\.\s*\$_SESSION/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
if ($file['name'] != 'excludefile.php') {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -499,12 +499,12 @@ class CodingPhpTest extends CommonClassTest
|
||||
|
||||
|
||||
// Test we don't have preg_grep with a param without preg_quote
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/preg_grep\(.*\$/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
if (strpos($val[0], 'preg_quote') === false) {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -512,62 +512,62 @@ class CodingPhpTest extends CommonClassTest
|
||||
|
||||
|
||||
// Test we don't have "if ($resql >"
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/if \(\$resql >/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
$this->assertTrue($ok, 'Found a if $resql with a > operator (when $resql is a boolean or resource) in file '.$file['relativename'].'. Please remove the > ... part.');
|
||||
|
||||
// Test we don't have empty($user->hasRight
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/empty\(\$user->hasRight/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
$this->assertTrue($ok, 'Found code empty($user->hasRight in file '.$file['relativename'].'. empty() must not be used on a var not on a function.');
|
||||
|
||||
// Test we don't have empty(DolibarrApiAccess::$user->hasRight
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/empty\(DolibarrApiAccess::\$user->hasRight/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
$this->assertTrue($ok, 'Found code empty(DolibarrApiAccess::$user->hasRight in file '.$file['relativename'].'. empty() must not be used on a var not on a function.');
|
||||
|
||||
// Test we don't have empty($user->hasRight
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/empty\(getDolGlobal/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
$this->assertTrue($ok, 'Found code empty(getDolGlobal... in file '.$file['relativename'].'. empty() must be used on a var not on a function.');
|
||||
|
||||
// Test we don't have @var array(
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/@var\s+array\(/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
$this->assertTrue($ok, 'Found a declaration @var array() instead of @var array in file '.$file['relativename'].'.');
|
||||
|
||||
|
||||
// Test we don't have CURDATE()
|
||||
$ok=true;
|
||||
$matches=array();
|
||||
$ok = true;
|
||||
$matches = array();
|
||||
preg_match_all('/CURDATE\(\)/', $filecontent, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $key => $val) {
|
||||
$ok=false;
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
$this->assertTrue($ok, 'Found a CURDATE\(\) into code. Do not use this SQL method in file '.$file['relativename'].'. You must use the PHP function dol_now() instead.');
|
||||
|
||||
@@ -68,7 +68,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -88,10 +88,10 @@ class CodingSqlTest extends CommonClassTest
|
||||
public function testEscape()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
if ($db->type == 'mysqli') {
|
||||
$a = 'abc"\'def'; // string is abc"'def
|
||||
@@ -115,10 +115,10 @@ class CodingSqlTest extends CommonClassTest
|
||||
public function testEscapeForLike()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$a = 'abc"\'def_ghi%klm\\nop';
|
||||
//print $a;
|
||||
@@ -134,10 +134,10 @@ class CodingSqlTest extends CommonClassTest
|
||||
public function testSql()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$listofsqldir = array(DOL_DOCUMENT_ROOT.'/install/mysql/data', DOL_DOCUMENT_ROOT.'/install/mysql/tables', DOL_DOCUMENT_ROOT.'/install/mysql/migration');
|
||||
|
||||
@@ -161,37 +161,37 @@ class CodingSqlTest extends CommonClassTest
|
||||
//$filecontent = preg_replace('/^--.*$/', '', $filecontent);
|
||||
$filecontent = preg_replace('/--.*?\n/', '', $filecontent);
|
||||
|
||||
$result=strpos($filecontent, '`');
|
||||
$result = strpos($filecontent, '`');
|
||||
//print __METHOD__." Result for checking we don't have back quote = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found back quote into '.$file.'. Bad.');
|
||||
$this->assertTrue($result === false, 'Found back quote into '.$file.'. Bad.');
|
||||
|
||||
$result=strpos($filecontent, '"');
|
||||
$result = strpos($filecontent, '"');
|
||||
//print __METHOD__." Result for checking we don't have double quote = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found double quote that is not [" neither {" (used for json content) neither (" (used for content with string like isModEnabled("")) into '.$file.'. Bad.');
|
||||
$this->assertTrue($result === false, 'Found double quote that is not [" neither {" (used for json content) neither (" (used for content with string like isModEnabled("")) into '.$file.'. Bad.');
|
||||
|
||||
$result=strpos($filecontent, 'int(');
|
||||
$result = strpos($filecontent, 'int(');
|
||||
//print __METHOD__." Result for checking we don't have 'int(' instead of 'integer' = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found int(x) or tinyint(x) instead of integer or tinyint into '.$file.'. Bad.');
|
||||
$this->assertTrue($result === false, 'Found int(x) or tinyint(x) instead of integer or tinyint into '.$file.'. Bad.');
|
||||
|
||||
$result=strpos($filecontent, 'ON DELETE CASCADE');
|
||||
$result = strpos($filecontent, 'ON DELETE CASCADE');
|
||||
//print __METHOD__." Result for checking we don't have 'ON DELETE CASCADE' = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found ON DELETE CASCADE into '.$file.'. Bad.');
|
||||
$this->assertTrue($result === false, 'Found ON DELETE CASCADE into '.$file.'. Bad.');
|
||||
|
||||
$result=strpos($filecontent, 'NUMERIC(');
|
||||
$result = strpos($filecontent, 'NUMERIC(');
|
||||
//print __METHOD__." Result for checking we don't have 'NUMERIC(' = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found NUMERIC( into '.$file.'. Bad.');
|
||||
$this->assertTrue($result === false, 'Found NUMERIC( into '.$file.'. Bad.');
|
||||
|
||||
$result=strpos($filecontent, 'NUMERIC(');
|
||||
$result = strpos($filecontent, 'NUMERIC(');
|
||||
//print __METHOD__." Result for checking we don't have 'curdate(' = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found curdate( into '.$file.'. Bad. Current date must be generated with PHP.');
|
||||
$this->assertTrue($result === false, 'Found curdate( into '.$file.'. Bad. Current date must be generated with PHP.');
|
||||
|
||||
$result=strpos($filecontent, 'integer(');
|
||||
$result = strpos($filecontent, 'integer(');
|
||||
//print __METHOD__." Result for checking we don't have 'integer(' = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found value in parenthesis after the integer. It must be integer not integer(x) into '.$file.'. Bad.');
|
||||
$this->assertTrue($result === false, 'Found value in parenthesis after the integer. It must be integer not integer(x) into '.$file.'. Bad.');
|
||||
|
||||
$result=strpos($filecontent, 'timestamp,');
|
||||
$result = strpos($filecontent, 'timestamp,');
|
||||
//print __METHOD__." Result for checking we don't have 'NUMERIC(' = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found type timestamp with option DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP after into '.$file.'. Bad.');
|
||||
$this->assertTrue($result === false, 'Found type timestamp with option DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP after into '.$file.'. Bad.');
|
||||
|
||||
if ($dir == DOL_DOCUMENT_ROOT.'/install/mysql/migration') {
|
||||
// Test for migration files only
|
||||
@@ -202,11 +202,11 @@ class CodingSqlTest extends CommonClassTest
|
||||
// Test for key files only
|
||||
} else {
|
||||
// Test for non key files only
|
||||
$result=(strpos($filecontent, 'KEY ') && strpos($filecontent, 'PRIMARY KEY') == 0);
|
||||
$result = (strpos($filecontent, 'KEY ') && strpos($filecontent, 'PRIMARY KEY') == 0);
|
||||
//print __METHOD__." Result for checking we don't have ' KEY ' instead of a sql file to create index = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found KEY into '.$file.'. Bad.');
|
||||
$this->assertTrue($result === false, 'Found KEY into '.$file.'. Bad.');
|
||||
|
||||
$result=stripos($filecontent, 'ENGINE=innodb');
|
||||
$result = stripos($filecontent, 'ENGINE=innodb');
|
||||
//print __METHOD__." Result for checking we have the ENGINE=innodb string = ".$result."\n";
|
||||
$this->assertGreaterThan(0, $result, 'The ENGINE=innodb was not found into '.$file.'. Add it or just fix syntax to match case.');
|
||||
}
|
||||
@@ -225,10 +225,10 @@ class CodingSqlTest extends CommonClassTest
|
||||
public function testInitData()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$filesarray = scandir(DOL_DOCUMENT_ROOT.'/../dev/initdemo');
|
||||
foreach ($filesarray as $key => $file) {
|
||||
@@ -237,19 +237,19 @@ class CodingSqlTest extends CommonClassTest
|
||||
}
|
||||
|
||||
print 'Check sql file '.$file."\n";
|
||||
$filecontent=file_get_contents(DOL_DOCUMENT_ROOT.'/../dev/initdemo/'.$file);
|
||||
$filecontent = file_get_contents(DOL_DOCUMENT_ROOT.'/../dev/initdemo/'.$file);
|
||||
|
||||
$result=strpos($filecontent, '@gmail.com');
|
||||
$result = strpos($filecontent, '@gmail.com');
|
||||
print __METHOD__." Result for checking we don't have personal data = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found a bad key @gmail into file '.$file);
|
||||
$this->assertTrue($result === false, 'Found a bad key @gmail into file '.$file);
|
||||
|
||||
$result=strpos($filecontent, 'eldy@');
|
||||
$result = strpos($filecontent, 'eldy@');
|
||||
print __METHOD__." Result for checking we don't have personal data = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found a bad key eldy@ into file '.$file);
|
||||
$this->assertTrue($result === false, 'Found a bad key eldy@ into file '.$file);
|
||||
|
||||
$result=strpos($filecontent, 'INSERT INTO `llx_oauth_token`');
|
||||
$result = strpos($filecontent, 'INSERT INTO `llx_oauth_token`');
|
||||
print __METHOD__." Result for checking we don't have data into llx_oauth_token = ".$result."\n";
|
||||
$this->assertTrue($result===false, 'Found a non expected insert into file '.$file);
|
||||
$this->assertTrue($result === false, 'Found a non expected insert into file '.$file);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -37,7 +37,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
|
||||
@@ -58,71 +58,71 @@ class CommandeFournisseurTest extends CommonClassTest
|
||||
public function testCommandeFournisseurCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// Set supplier and product to use
|
||||
$socid=1;
|
||||
$societe=new Societe($db);
|
||||
$socid = 1;
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($socid);
|
||||
$product=new ProductFournisseur($db);
|
||||
$product = new ProductFournisseur($db);
|
||||
$product->fetch(0, 'PINKDRESS');
|
||||
if ($product->id <= 0) {
|
||||
print "\n".__METHOD__." A product with ref PINKDRESS must exists into database";
|
||||
die(1);
|
||||
}
|
||||
|
||||
$quantity=10;
|
||||
$ref_fourn='SUPPLIER_REF_PHPUNIT';
|
||||
$tva_tx=19.6;
|
||||
$quantity = 10;
|
||||
$ref_fourn = 'SUPPLIER_REF_PHPUNIT';
|
||||
$tva_tx = 19.6;
|
||||
|
||||
// Delete existing supplier prices
|
||||
// TODO
|
||||
|
||||
// Create 1 supplier price with min qty = 10;
|
||||
$result=$product->add_fournisseur($user, $societe->id, $ref_fourn, $quantity); // This insert record with no value for price. Values are update later with update_buyprice
|
||||
$result = $product->add_fournisseur($user, $societe->id, $ref_fourn, $quantity); // This insert record with no value for price. Values are update later with update_buyprice
|
||||
print __METHOD__." add_fournisseur result=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(0, $result, 'Create 1 supplier price with min qty = 10 if not exists');
|
||||
$result=$product->update_buyprice($quantity, 20, $user, 'HT', $societe, '', $ref_fourn, $tva_tx, 0, 0);
|
||||
$result = $product->update_buyprice($quantity, 20, $user, 'HT', $societe, '', $ref_fourn, $tva_tx, 0, 0);
|
||||
print __METHOD__." update_buyprice result=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(0, $result, 'Update buyprice');
|
||||
|
||||
// Create purchase order with a too low quantity and option SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY is on
|
||||
$conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY = 1;
|
||||
|
||||
$localobject=new CommandeFournisseur($db);
|
||||
$localobject = new CommandeFournisseur($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->lines=array(); // Overwrite lines of order
|
||||
$line=new CommandeFournisseurLigne($db);
|
||||
$line->desc=$langs->trans("Description")." specimen line with qty too low";
|
||||
$line->qty=1; // So lower than $quantity
|
||||
$line->subprice=100;
|
||||
$line->fk_product=$product->id;
|
||||
$line->ref_fourn=$ref_fourn;
|
||||
$localobject->lines[]=$line;
|
||||
$localobject->lines = array(); // Overwrite lines of order
|
||||
$line = new CommandeFournisseurLigne($db);
|
||||
$line->desc = $langs->trans("Description")." specimen line with qty too low";
|
||||
$line->qty = 1; // So lower than $quantity
|
||||
$line->subprice = 100;
|
||||
$line->fk_product = $product->id;
|
||||
$line->ref_fourn = $ref_fourn;
|
||||
$localobject->lines[] = $line;
|
||||
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(-1, $result, 'Creation of too low quantity'); // must be -1 because quantity is lower than minimum of supplier price
|
||||
|
||||
$sql="DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where ref IN ('', '(PROV)')";
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where ref IN ('', '(PROV)')";
|
||||
$db->query($sql);
|
||||
|
||||
// Create purchase order
|
||||
$localobject2=new CommandeFournisseur($db);
|
||||
$localobject2 = new CommandeFournisseur($db);
|
||||
$localobject2->initAsSpecimen(); // This create 5 lines of first product found for socid 1
|
||||
$localobject2->lines=array(); // Overwrite lines of order
|
||||
$line=new CommandeFournisseurLigne($db);
|
||||
$line->desc=$langs->trans("Description")." specimen line ok";
|
||||
$line->qty=10; // So enough quantity
|
||||
$line->subprice=100;
|
||||
$line->fk_product=$product->id;
|
||||
$line->ref_fourn=$ref_fourn;
|
||||
$localobject2->lines[]=$line;
|
||||
$localobject2->lines = array(); // Overwrite lines of order
|
||||
$line = new CommandeFournisseurLigne($db);
|
||||
$line->desc = $langs->trans("Description")." specimen line ok";
|
||||
$line->qty = 10; // So enough quantity
|
||||
$line->subprice = 100;
|
||||
$line->fk_product = $product->id;
|
||||
$line->ref_fourn = $ref_fourn;
|
||||
$localobject2->lines[] = $line;
|
||||
|
||||
$result=$localobject2->create($user);
|
||||
$result = $localobject2->create($user);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
|
||||
@@ -130,37 +130,37 @@ class CommandeFournisseurTest extends CommonClassTest
|
||||
// Create purchase order with a too low quantity but option SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY is off
|
||||
$conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY = 0;
|
||||
|
||||
$localobject3=new CommandeFournisseur($db);
|
||||
$localobject3 = new CommandeFournisseur($db);
|
||||
$localobject3->initAsSpecimen();
|
||||
$localobject3->lines=array(); // Overwrite lines of order
|
||||
$line=new CommandeFournisseurLigne($db);
|
||||
$line->desc=$langs->trans("Description")." specimen line with qty too low";
|
||||
$line->qty=1; // So lower than $quantity
|
||||
$line->subprice=100;
|
||||
$line->fk_product=$product->id;
|
||||
$line->ref_fourn=$ref_fourn;
|
||||
$localobject3->lines[]=$line;
|
||||
$localobject3->lines = array(); // Overwrite lines of order
|
||||
$line = new CommandeFournisseurLigne($db);
|
||||
$line->desc = $langs->trans("Description")." specimen line with qty too low";
|
||||
$line->qty = 1; // So lower than $quantity
|
||||
$line->subprice = 100;
|
||||
$line->fk_product = $product->id;
|
||||
$line->ref_fourn = $ref_fourn;
|
||||
$localobject3->lines[] = $line;
|
||||
|
||||
$result=$localobject3->create($user);
|
||||
$result = $localobject3->create($user);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result, 'Creation of too low quantity should be ok'); // must be id of line because there is no test on minimum quantity
|
||||
|
||||
$sql="DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where ref=''";
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where ref=''";
|
||||
$db->query($sql);
|
||||
|
||||
// Create purchase order
|
||||
$localobject4=new CommandeFournisseur($db);
|
||||
$localobject4 = new CommandeFournisseur($db);
|
||||
$localobject4->initAsSpecimen(); // This create 5 lines of first product found for socid 1
|
||||
$localobject4->lines=array(); // Overwrite lines of order
|
||||
$line=new CommandeFournisseurLigne($db);
|
||||
$line->desc=$langs->trans("Description")." specimen line ok";
|
||||
$line->qty=10; // So enough quantity
|
||||
$line->subprice=100;
|
||||
$line->fk_product=$product->id;
|
||||
$line->ref_fourn=$ref_fourn;
|
||||
$localobject4->lines[]=$line;
|
||||
$localobject4->lines = array(); // Overwrite lines of order
|
||||
$line = new CommandeFournisseurLigne($db);
|
||||
$line->desc = $langs->trans("Description")." specimen line ok";
|
||||
$line->qty = 10; // So enough quantity
|
||||
$line->subprice = 100;
|
||||
$line->fk_product = $product->id;
|
||||
$line->ref_fourn = $ref_fourn;
|
||||
$localobject4->lines[] = $line;
|
||||
|
||||
$result=$localobject4->create($user);
|
||||
$result = $localobject4->create($user);
|
||||
print __METHOD__." id for purchase order created by testCommandeFournisseurCreate = ".$result."\n";
|
||||
$this->assertGreaterThan(0, $result, 'Test to create a purchase order by testCommandeFournisseurCreate');
|
||||
|
||||
@@ -180,13 +180,13 @@ class CommandeFournisseurTest extends CommonClassTest
|
||||
public function testCommandeFournisseurFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new CommandeFournisseur($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new CommandeFournisseur($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, 'Failed to fetch supplier order with id '.$id);
|
||||
@@ -205,12 +205,12 @@ class CommandeFournisseurTest extends CommonClassTest
|
||||
public function testCommandeFournisseurValid($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->valid($user);
|
||||
$result = $localobject->valid($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -229,12 +229,12 @@ class CommandeFournisseurTest extends CommonClassTest
|
||||
public function testCommandeFournisseurApprove($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->approve($user);
|
||||
$result = $localobject->approve($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -253,12 +253,12 @@ class CommandeFournisseurTest extends CommonClassTest
|
||||
public function testCommandeFournisseurCancel($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->cancel($user);
|
||||
$result = $localobject->cancel($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -277,10 +277,10 @@ class CommandeFournisseurTest extends CommonClassTest
|
||||
public function testCommandeFournisseurOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
/*$result=$localobject->setstatus(0);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
@@ -308,14 +308,14 @@ class CommandeFournisseurTest extends CommonClassTest
|
||||
public function testCommandeFournisseurDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new CommandeFournisseur($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new CommandeFournisseur($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -75,20 +75,20 @@ class CommandeTest extends CommonClassTest
|
||||
public function testCommandeCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$soc = new Societe($db);
|
||||
$soc->name = "CommandeTest Unittest";
|
||||
$socid = $soc->create($user);
|
||||
$this->assertLessThan($socid, 0, $soc->errorsToString());
|
||||
|
||||
$localobject=new Commande($db);
|
||||
$localobject = new Commande($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->socid = $socid;
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
$this->assertLessThan($result, 0, $localobject->errorsToString());
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -107,13 +107,13 @@ class CommandeTest extends CommonClassTest
|
||||
public function testCommandeFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Commande($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Commande($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
@@ -132,13 +132,13 @@ class CommandeTest extends CommonClassTest
|
||||
public function testCommandeUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->note_private='New note private after update';
|
||||
$result=$localobject->update($user);
|
||||
$localobject->note_private = 'New note private after update';
|
||||
$result = $localobject->update($user);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
@@ -157,12 +157,12 @@ class CommandeTest extends CommonClassTest
|
||||
public function testCommandeValid($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->valid($user);
|
||||
$result = $localobject->valid($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -181,12 +181,12 @@ class CommandeTest extends CommonClassTest
|
||||
public function testCommandeCancel($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->cancel();
|
||||
$result = $localobject->cancel();
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -205,10 +205,10 @@ class CommandeTest extends CommonClassTest
|
||||
public function testCommandeOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
/*$result=$localobject->setstatus(0);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
@@ -234,14 +234,14 @@ class CommandeTest extends CommonClassTest
|
||||
public function testCommandeDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Commande($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new Commande($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -34,7 +34,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -63,10 +63,10 @@ class CommonClassTest extends PHPUnit\Framework\TestCase
|
||||
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$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;
|
||||
@@ -128,10 +128,10 @@ class CommonClassTest extends PHPUnit\Framework\TestCase
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
//print $db->getVersion()."\n";
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,12 +56,12 @@ class CommonInvoiceTest extends CommonClassTest
|
||||
public function testCalculateDateLimReglement()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->fetch(1);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 1, 1, 2010);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -57,15 +57,15 @@ class CommonObjectTest extends CommonClassTest
|
||||
public function testFetchUser()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Commande($db);
|
||||
$localobject = new Commande($db);
|
||||
$localobject->fetch(1);
|
||||
|
||||
$result=$localobject->fetch_user(1);
|
||||
$result = $localobject->fetch_user(1);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($localobject->user->id, 0);
|
||||
@@ -80,14 +80,14 @@ class CommonObjectTest extends CommonClassTest
|
||||
public function testFetchProject()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Commande($db);
|
||||
$localobject = new Commande($db);
|
||||
$localobject->fetch(1);
|
||||
$result=$localobject->fetch_projet();
|
||||
$result = $localobject->fetch_projet();
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThanOrEqual($result, 0);
|
||||
@@ -102,15 +102,15 @@ class CommonObjectTest extends CommonClassTest
|
||||
public function testFetchThirdParty()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Commande($db);
|
||||
$localobject = new Commande($db);
|
||||
$localobject->fetch(1);
|
||||
|
||||
$result=$localobject->fetch_thirdparty();
|
||||
$result = $localobject->fetch_thirdparty();
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThanOrEqual($result, 0);
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,20 +56,20 @@ class CompanyBankAccountTest extends CommonClassTest
|
||||
public function testCompanyBankAccountCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$soc = new Societe($db);
|
||||
$soc->name = "CompanyBankAccountTest Unittest";
|
||||
$socid = $soc->create($user);
|
||||
$this->assertLessThan($socid, 0, $soc->errorsToString());
|
||||
|
||||
$localobject=new CompanyBankAccount($db);
|
||||
$localobject = new CompanyBankAccount($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->socid = $socid;
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
print __METHOD__." result=".$result." id=".$localobject->id."\n";
|
||||
$this->assertLessThan($result, 0, $localobject->errorsToString());
|
||||
@@ -88,13 +88,13 @@ class CompanyBankAccountTest extends CommonClassTest
|
||||
public function testCompanyBankAccountFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new CompanyBankAccount($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new CompanyBankAccount($db);
|
||||
$result = $localobject->fetch($id);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
@@ -111,12 +111,12 @@ class CompanyBankAccountTest extends CommonClassTest
|
||||
public function testCompanyBankAccountSetAsDefault($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->setAsDefault($localobject->id);
|
||||
$result = $localobject->setAsDefault($localobject->id);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
@@ -134,13 +134,13 @@ class CompanyBankAccountTest extends CommonClassTest
|
||||
public function testCompanyBankAccountUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->owner='New owner';
|
||||
$result=$localobject->update($user);
|
||||
$localobject->owner = 'New owner';
|
||||
$result = $localobject->update($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -159,13 +159,13 @@ class CompanyBankAccountTest extends CommonClassTest
|
||||
public function testCompanyBankAccountOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->owner='New owner';
|
||||
$result=$localobject->update($user);
|
||||
$localobject->owner = 'New owner';
|
||||
$result = $localobject->update($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,19 +56,19 @@ class CompanyLibTest extends CommonClassTest
|
||||
public function testNameCurrency()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=currency_name('USD');
|
||||
$result = currency_name('USD');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('US Dollars', $result, 'Test to get currency name USD in default language '.$langs->defaultlang);
|
||||
|
||||
$outputlangs=new Translate('', $conf);
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang('fr_FR');
|
||||
|
||||
$result=currency_name('USD', 1, $outputlangs);
|
||||
$result = currency_name('USD', 1, $outputlangs);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('USD - Dollars US', $result, 'Test to get currency name USD in default language '.$outputlangs->getDefaultLang());
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ if (empty($user->id)) {
|
||||
$user->getrights();
|
||||
}
|
||||
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -64,14 +64,14 @@ class ContactTest extends CommonClassTest
|
||||
public function testContactCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Contact($db);
|
||||
$localobject = new Contact($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -90,13 +90,13 @@ class ContactTest extends CommonClassTest
|
||||
public function testContactFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Contact($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Contact($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -116,44 +116,44 @@ class ContactTest extends CommonClassTest
|
||||
public function testContactUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->oldcopy = clone $localobject;
|
||||
|
||||
$localobject->note_private='New private note after update';
|
||||
$localobject->note_public='New public note after update';
|
||||
$localobject->lastname='New name';
|
||||
$localobject->firstname='New firstname';
|
||||
$localobject->address='New address';
|
||||
$localobject->zip='New zip';
|
||||
$localobject->town='New town';
|
||||
$localobject->country_id=2;
|
||||
$localobject->note_private = 'New private note after update';
|
||||
$localobject->note_public = 'New public note after update';
|
||||
$localobject->lastname = 'New name';
|
||||
$localobject->firstname = 'New firstname';
|
||||
$localobject->address = 'New address';
|
||||
$localobject->zip = 'New zip';
|
||||
$localobject->town = 'New town';
|
||||
$localobject->country_id = 2;
|
||||
//$localobject->status=0;
|
||||
$localobject->phone_pro='New tel pro';
|
||||
$localobject->phone_perso='New tel perso';
|
||||
$localobject->phone_mobile='New tel mobile';
|
||||
$localobject->fax='New fax';
|
||||
$localobject->email='newemail@newemail.com';
|
||||
$localobject->socialnetworks['jabber']='New im id';
|
||||
$localobject->default_lang='es_ES';
|
||||
$localobject->phone_pro = 'New tel pro';
|
||||
$localobject->phone_perso = 'New tel perso';
|
||||
$localobject->phone_mobile = 'New tel mobile';
|
||||
$localobject->fax = 'New fax';
|
||||
$localobject->email = 'newemail@newemail.com';
|
||||
$localobject->socialnetworks['jabber'] = 'New im id';
|
||||
$localobject->default_lang = 'es_ES';
|
||||
|
||||
$result=$localobject->update($localobject->id, $user);
|
||||
$result = $localobject->update($localobject->id, $user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, 'Contact::update error');
|
||||
|
||||
$result=$localobject->update_note($localobject->note_private, '_private');
|
||||
$result = $localobject->update_note($localobject->note_private, '_private');
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, 'Contact::update_note (private) error');
|
||||
|
||||
$result=$localobject->update_note($localobject->note_public, '_public');
|
||||
$result = $localobject->update_note($localobject->note_public, '_public');
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, 'Contact::update_note (public) error');
|
||||
|
||||
$newobject=new Contact($db);
|
||||
$result=$newobject->fetch($localobject->id);
|
||||
$newobject = new Contact($db);
|
||||
$result = $newobject->fetch($localobject->id);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, 'Contact::fetch error');
|
||||
|
||||
@@ -207,18 +207,18 @@ class ContactTest extends CommonClassTest
|
||||
public function testContactOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
//$localobject->fetch($localobject->id);
|
||||
|
||||
$result=$localobject->getNomUrl(1);
|
||||
$result = $localobject->getNomUrl(1);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertNotEquals($result, '');
|
||||
|
||||
$result=$localobject->getFullAddress(1);
|
||||
$result = $localobject->getFullAddress(1);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertStringContainsString("New address\nNew zip New town\nBelgium", $result);
|
||||
|
||||
@@ -241,15 +241,15 @@ class ContactTest extends CommonClassTest
|
||||
public function testContactDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Contact($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Contact($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$result=$localobject->delete($user);
|
||||
$result = $localobject->delete($user);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -264,55 +264,55 @@ class ContactTest extends CommonClassTest
|
||||
public function testContactGetFullAddress()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobjectadd=new Contact($db);
|
||||
$localobjectadd = new Contact($db);
|
||||
$localobjectadd->initAsSpecimen();
|
||||
|
||||
// France
|
||||
unset($localobjectadd->country_code);
|
||||
$localobjectadd->country_id=1;
|
||||
$localobjectadd->name='New name';
|
||||
$localobjectadd->address='New address';
|
||||
$localobjectadd->zip='New zip';
|
||||
$localobjectadd->town='New town';
|
||||
$result=$localobjectadd->getFullAddress(1);
|
||||
$localobjectadd->country_id = 1;
|
||||
$localobjectadd->name = 'New name';
|
||||
$localobjectadd->address = 'New address';
|
||||
$localobjectadd->zip = 'New zip';
|
||||
$localobjectadd->town = 'New town';
|
||||
$result = $localobjectadd->getFullAddress(1);
|
||||
print __METHOD__." id=".$localobjectadd->id." result=".$result."\n";
|
||||
$this->assertStringContainsString("New address\nNew zip New town\nFrance", $result);
|
||||
|
||||
// Belgium
|
||||
unset($localobjectadd->country_code);
|
||||
$localobjectadd->country_id=2;
|
||||
$localobjectadd->name='New name';
|
||||
$localobjectadd->address='New address';
|
||||
$localobjectadd->zip='New zip';
|
||||
$localobjectadd->town='New town';
|
||||
$result=$localobjectadd->getFullAddress(1);
|
||||
$localobjectadd->country_id = 2;
|
||||
$localobjectadd->name = 'New name';
|
||||
$localobjectadd->address = 'New address';
|
||||
$localobjectadd->zip = 'New zip';
|
||||
$localobjectadd->town = 'New town';
|
||||
$result = $localobjectadd->getFullAddress(1);
|
||||
print __METHOD__." id=".$localobjectadd->id." result=".$result."\n";
|
||||
$this->assertStringContainsString("New address\nNew zip New town\nBelgium", $result);
|
||||
|
||||
// Switzerland
|
||||
unset($localobjectadd->country_code);
|
||||
$localobjectadd->country_id=6;
|
||||
$localobjectadd->name='New name';
|
||||
$localobjectadd->address='New address';
|
||||
$localobjectadd->zip='New zip';
|
||||
$localobjectadd->town='New town';
|
||||
$result=$localobjectadd->getFullAddress(1);
|
||||
$localobjectadd->country_id = 6;
|
||||
$localobjectadd->name = 'New name';
|
||||
$localobjectadd->address = 'New address';
|
||||
$localobjectadd->zip = 'New zip';
|
||||
$localobjectadd->town = 'New town';
|
||||
$result = $localobjectadd->getFullAddress(1);
|
||||
print __METHOD__." id=".$localobjectadd->id." result=".$result."\n";
|
||||
$this->assertStringContainsString("New address\nNew zip New town\nSwitzerland", $result);
|
||||
|
||||
// USA
|
||||
unset($localobjectadd->country_code);
|
||||
$localobjectadd->country_id=11;
|
||||
$localobjectadd->name='New name';
|
||||
$localobjectadd->address='New address';
|
||||
$localobjectadd->zip='New zip';
|
||||
$localobjectadd->town='New town';
|
||||
$result=$localobjectadd->getFullAddress(1);
|
||||
$localobjectadd->country_id = 11;
|
||||
$localobjectadd->name = 'New name';
|
||||
$localobjectadd->address = 'New address';
|
||||
$localobjectadd->zip = 'New zip';
|
||||
$localobjectadd->town = 'New town';
|
||||
$result = $localobjectadd->getFullAddress(1);
|
||||
print __METHOD__." id=".$localobjectadd->id." result=".$result."\n";
|
||||
$this->assertStringContainsString("New address\nNew town, New zip\nUnited States", $result);
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,20 +56,20 @@ class ContratTest extends CommonClassTest
|
||||
public function testContratCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$soc = new Societe($db);
|
||||
$soc->name = "ContratTest Unittest";
|
||||
$socid = $soc->create($user);
|
||||
$this->assertLessThan($socid, 0, $soc->errorsToString());
|
||||
|
||||
$localobject=new Contrat($db);
|
||||
$localobject = new Contrat($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->socid = $socid;
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, $localobject->errorsToString());
|
||||
@@ -89,13 +89,13 @@ class ContratTest extends CommonClassTest
|
||||
public function testContratFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Contrat($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Contrat($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -115,10 +115,10 @@ class ContratTest extends CommonClassTest
|
||||
public function testContratOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
/*$result=$localobject->setstatus(0);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
@@ -144,14 +144,14 @@ class ContratTest extends CommonClassTest
|
||||
public function testContratDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Contrat($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new Contrat($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -92,7 +92,7 @@ class CoreTest extends CommonClassTest
|
||||
global $dolibarr_main_db_type;
|
||||
global $dolibarr_main_db_prefix;
|
||||
|
||||
$testtodo=0;
|
||||
$testtodo = 0;
|
||||
|
||||
// Case 1:
|
||||
// Test for subdir dolibarrnew (that point to htdocs) in root directory /var/www
|
||||
@@ -101,12 +101,12 @@ class CoreTest extends CommonClassTest
|
||||
// - Create link from htdocs to /var/www/dolibarrnew
|
||||
// - Put into conf.php $dolibarr_main_document_root='/var/www/dolibarrnew';
|
||||
if ($testtodo == 1) {
|
||||
$_SERVER["HTTPS"]='';
|
||||
$_SERVER["SERVER_NAME"]='localhost';
|
||||
$_SERVER["SERVER_PORT"]='80';
|
||||
$_SERVER["DOCUMENT_ROOT"]='/var/www';
|
||||
$_SERVER["SCRIPT_NAME"]='/dolibarrnew/admin/system/phpinfo.php';
|
||||
$expectedresult='/dolibarrnew';
|
||||
$_SERVER["HTTPS"] = '';
|
||||
$_SERVER["SERVER_NAME"] = 'localhost';
|
||||
$_SERVER["SERVER_PORT"] = '80';
|
||||
$_SERVER["DOCUMENT_ROOT"] = '/var/www';
|
||||
$_SERVER["SCRIPT_NAME"] = '/dolibarrnew/admin/system/phpinfo.php';
|
||||
$expectedresult = '/dolibarrnew';
|
||||
}
|
||||
|
||||
// Case 2:
|
||||
@@ -116,12 +116,12 @@ class CoreTest extends CommonClassTest
|
||||
// - Create link from dolibarr to /var/www/aaa
|
||||
// - Put into conf.php $dolibarr_main_document_root='/var/www/aaa/htdocs';
|
||||
if ($testtodo == 2) {
|
||||
$_SERVER["HTTPS"]='';
|
||||
$_SERVER["SERVER_NAME"]='localhost';
|
||||
$_SERVER["SERVER_PORT"]='80';
|
||||
$_SERVER["DOCUMENT_ROOT"]='/var/www';
|
||||
$_SERVER["SCRIPT_NAME"]='/aaa/htdocs/admin/system/phpinfo.php';
|
||||
$expectedresult='/aaa/htdocs';
|
||||
$_SERVER["HTTPS"] = '';
|
||||
$_SERVER["SERVER_NAME"] = 'localhost';
|
||||
$_SERVER["SERVER_PORT"] = '80';
|
||||
$_SERVER["DOCUMENT_ROOT"] = '/var/www';
|
||||
$_SERVER["SCRIPT_NAME"] = '/aaa/htdocs/admin/system/phpinfo.php';
|
||||
$expectedresult = '/aaa/htdocs';
|
||||
}
|
||||
|
||||
// Case 3:
|
||||
@@ -132,12 +132,12 @@ class CoreTest extends CommonClassTest
|
||||
// - Create virtual host localhostdolibarrnew that point to /home/ldestailleur/git/dolibarr/htdocs
|
||||
// - Put into conf.php $dolibarr_main_document_root='/home/ldestailleur/git/dolibarr/htdocs';
|
||||
if ($testtodo == 3) {
|
||||
$_SERVER["HTTPS"]='';
|
||||
$_SERVER["SERVER_NAME"]='localhostdolibarrnew';
|
||||
$_SERVER["SERVER_PORT"]='80';
|
||||
$_SERVER["DOCUMENT_ROOT"]='/home/ldestailleur/git/dolibarr/htdocs';
|
||||
$_SERVER["SCRIPT_NAME"]='/admin/system/phpinfo.php';
|
||||
$expectedresult='';
|
||||
$_SERVER["HTTPS"] = '';
|
||||
$_SERVER["SERVER_NAME"] = 'localhostdolibarrnew';
|
||||
$_SERVER["SERVER_PORT"] = '80';
|
||||
$_SERVER["DOCUMENT_ROOT"] = '/home/ldestailleur/git/dolibarr/htdocs';
|
||||
$_SERVER["SCRIPT_NAME"] = '/admin/system/phpinfo.php';
|
||||
$expectedresult = '';
|
||||
}
|
||||
|
||||
// Case 4:
|
||||
@@ -145,12 +145,12 @@ class CoreTest extends CommonClassTest
|
||||
// a symbolic link
|
||||
// URL: http://localhostdolibarrnew/admin/system/phpinfo.php
|
||||
if ($testtodo == 4) {
|
||||
$_SERVER["HTTPS"]='';
|
||||
$_SERVER["SERVER_NAME"]='localhostdolibarrnew';
|
||||
$_SERVER["SERVER_PORT"]='80';
|
||||
$_SERVER["DOCUMENT_ROOT"]='/var/www/dolibarr'; // This is a link that point to /home/ldestail/workspace/dolibarr/htdocs
|
||||
$_SERVER["SCRIPT_NAME"]='/admin/system/phpinfo.php';
|
||||
$expectedresult='';
|
||||
$_SERVER["HTTPS"] = '';
|
||||
$_SERVER["SERVER_NAME"] = 'localhostdolibarrnew';
|
||||
$_SERVER["SERVER_PORT"] = '80';
|
||||
$_SERVER["DOCUMENT_ROOT"] = '/var/www/dolibarr'; // This is a link that point to /home/ldestail/workspace/dolibarr/htdocs
|
||||
$_SERVER["SCRIPT_NAME"] = '/admin/system/phpinfo.php';
|
||||
$expectedresult = '';
|
||||
}
|
||||
|
||||
// Case 5:
|
||||
@@ -161,12 +161,12 @@ class CoreTest extends CommonClassTest
|
||||
// - Put into conf.php $dolibarr_main_document_root='/var/www/dolibarr/htdocs';
|
||||
// - Put into conf.php $dolibarr_main_url_root='http://localhost/dolibarralias'; (because autodetect will fails in this case)
|
||||
if ($testtodo == 5) {
|
||||
$_SERVER["HTTPS"]='';
|
||||
$_SERVER["SERVER_NAME"]='localhost';
|
||||
$_SERVER["SERVER_PORT"]='80';
|
||||
$_SERVER["DOCUMENT_ROOT"]='/var/www';
|
||||
$_SERVER["SCRIPT_NAME"]='/dolibarralias/admin/system/phpinfo.php';
|
||||
$expectedresult='/dolibarralias';
|
||||
$_SERVER["HTTPS"] = '';
|
||||
$_SERVER["SERVER_NAME"] = 'localhost';
|
||||
$_SERVER["SERVER_PORT"] = '80';
|
||||
$_SERVER["DOCUMENT_ROOT"] = '/var/www';
|
||||
$_SERVER["SCRIPT_NAME"] = '/dolibarralias/admin/system/phpinfo.php';
|
||||
$expectedresult = '/dolibarralias';
|
||||
}
|
||||
|
||||
// Force to rerun filefunc.inc.php
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
print "\n".$langs->trans("CurrentTimeZone").' : '.getServerTimeZoneString();
|
||||
print "\n".$langs->trans("CurrentHour").' : '.dol_print_date(dol_now('gmt'), 'dayhour', 'tzserver');
|
||||
@@ -60,44 +60,44 @@ class DateLibTest extends CommonClassTest
|
||||
public function testNumBetweenDay()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// With same hours
|
||||
$date1=dol_mktime(0, 0, 0, 1, 1, 2012, 'gmt');
|
||||
$date2=dol_mktime(0, 0, 0, 1, 2, 2012, 'gmt');
|
||||
$date1 = dol_mktime(0, 0, 0, 1, 1, 2012, 'gmt');
|
||||
$date2 = dol_mktime(0, 0, 0, 1, 2, 2012, 'gmt');
|
||||
|
||||
$result=num_between_day($date1, $date2, 1);
|
||||
$result = num_between_day($date1, $date2, 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(2, $result);
|
||||
|
||||
$result=num_between_day($date1, $date2, 0);
|
||||
$result = num_between_day($date1, $date2, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(1, $result);
|
||||
|
||||
// With different hours
|
||||
$date1=dol_mktime(0, 0, 0, 1, 1, 2012, 'gmt');
|
||||
$date2=dol_mktime(12, 0, 0, 1, 2, 2012, 'gmt');
|
||||
$date1 = dol_mktime(0, 0, 0, 1, 1, 2012, 'gmt');
|
||||
$date2 = dol_mktime(12, 0, 0, 1, 2, 2012, 'gmt');
|
||||
|
||||
$result=num_between_day($date1, $date2, 1);
|
||||
$result = num_between_day($date1, $date2, 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(2, $result);
|
||||
|
||||
$result=num_between_day($date1, $date2, 0);
|
||||
$result = num_between_day($date1, $date2, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(1, $result);
|
||||
|
||||
// With different date before and after sunlight hour (day to change sunlight hour is 2014-03-30)
|
||||
$date1=dol_mktime(0, 0, 0, 3, 28, 2014, true);
|
||||
$date2=dol_mktime(0, 0, 0, 3, 31, 2014, true);
|
||||
$date1 = dol_mktime(0, 0, 0, 3, 28, 2014, true);
|
||||
$date2 = dol_mktime(0, 0, 0, 3, 31, 2014, true);
|
||||
|
||||
$result=num_between_day($date1, $date2, 1);
|
||||
$result = num_between_day($date1, $date2, 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(4, $result);
|
||||
|
||||
$result=num_between_day($date1, $date2, 0);
|
||||
$result = num_between_day($date1, $date2, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(3, $result);
|
||||
|
||||
@@ -112,62 +112,62 @@ class DateLibTest extends CommonClassTest
|
||||
public function testNumPublicHoliday()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// With same hours - Tuesday/Wednesday jan 2013
|
||||
$date1=dol_mktime(0, 0, 0, 1, 1, 2013, 'gmt');
|
||||
$date2=dol_mktime(0, 0, 0, 1, 2, 2013, 'gmt');
|
||||
$date3=dol_mktime(0, 0, 0, 1, 3, 2013, 'gmt');
|
||||
$date1 = dol_mktime(0, 0, 0, 1, 1, 2013, 'gmt');
|
||||
$date2 = dol_mktime(0, 0, 0, 1, 2, 2013, 'gmt');
|
||||
$date3 = dol_mktime(0, 0, 0, 1, 3, 2013, 'gmt');
|
||||
|
||||
$result=num_public_holiday($date1, $date2, 'FR', 1);
|
||||
$result = num_public_holiday($date1, $date2, 'FR', 1);
|
||||
print __METHOD__." for Tuesday 1 - Wednesday 2 jan 2013 for FR result=".$result."\n";
|
||||
$this->assertEquals(1, $result, 'NumPublicHoliday for Tuesday 1 - Wednesday 2 jan 2013 for FR'); // 1 closed days (country france)
|
||||
|
||||
$result=num_public_holiday($date1, $date2, 'XX', 1);
|
||||
$result = num_public_holiday($date1, $date2, 'XX', 1);
|
||||
print __METHOD__." for Tuesday 1 - Wednesday 2 jan 2013 for XX result=".$result."\n";
|
||||
$this->assertEquals(1, $result, 'NumPublicHoliday for Tuesday 1 - Wednesday 2 jan 2013 for XX'); // 1 closed days (country unknown)
|
||||
|
||||
print '----'."\n";
|
||||
$result=num_public_holiday($date2, $date3, 'FR', 1);
|
||||
$result = num_public_holiday($date2, $date3, 'FR', 1);
|
||||
print __METHOD__." for Wednesday 2 - Thursday 3 jan 2013 for FR result=".$result."\n";
|
||||
$this->assertEquals(0, $result, 'NumPublicHoliday for Wednesday 2 - Thursday 3 jan 2013 for FR'); // no closed days
|
||||
|
||||
// Check with easter monday
|
||||
$date1=dol_mktime(0, 0, 0, 4, 21, 2019, 'gmt');
|
||||
$date2=dol_mktime(0, 0, 0, 4, 23, 2019, 'gmt');
|
||||
$date1 = dol_mktime(0, 0, 0, 4, 21, 2019, 'gmt');
|
||||
$date2 = dol_mktime(0, 0, 0, 4, 23, 2019, 'gmt');
|
||||
|
||||
$result=num_public_holiday($date1, $date2, 'XX', 1);
|
||||
$result = num_public_holiday($date1, $date2, 'XX', 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(1, $result, 'NumPublicHoliday including eastermonday for XX'); // 2 opened day, 1 closed days (sunday)
|
||||
|
||||
$result=num_public_holiday($date1, $date2, 'FR', 1);
|
||||
$result = num_public_holiday($date1, $date2, 'FR', 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(2, $result, 'NumPublicHoliday including eastermonday for FR'); // 1 opened day, 2 closed days (sunday + easter monday)
|
||||
|
||||
// Check for sunday/saturday - Friday 4 - Sunday 6 jan 2013
|
||||
$date1=dol_mktime(0, 0, 0, 1, 4, 2013, 'gmt');
|
||||
$date2=dol_mktime(0, 0, 0, 1, 6, 2013, 'gmt');
|
||||
$date1 = dol_mktime(0, 0, 0, 1, 4, 2013, 'gmt');
|
||||
$date2 = dol_mktime(0, 0, 0, 1, 6, 2013, 'gmt');
|
||||
|
||||
$result=num_public_holiday($date1, $date2, 'FR', 1);
|
||||
$result = num_public_holiday($date1, $date2, 'FR', 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(2, $result, 'NumPublicHoliday for FR'); // 1 opened day, 2 closed days
|
||||
|
||||
$result=num_public_holiday($date1, $date2, 'FR', 1, 1, 1);
|
||||
$result = num_public_holiday($date1, $date2, 'FR', 1, 1, 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(2, $result, 'NumPublicHoliday for FR'); // 1 opened day, 2 closed days
|
||||
|
||||
$result=num_public_holiday($date1, $date2, 'FR', 1, 1, 0);
|
||||
$result = num_public_holiday($date1, $date2, 'FR', 1, 1, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(1, $result, 'NumPublicHoliday for FR'); // 2 opened day, 1 closed days
|
||||
|
||||
$result=num_public_holiday($date1, $date2, 'FR', 1, 0, 0);
|
||||
$result = num_public_holiday($date1, $date2, 'FR', 1, 0, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(0, $result, 'NumPublicHoliday for FR'); // 3 opened day, 0 closed days
|
||||
|
||||
$result=num_public_holiday($date1, $date2, 'XX', 1);
|
||||
$result = num_public_holiday($date1, $date2, 'XX', 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(2, $result, 'NumPublicHoliday for XX'); // 1 opened day, 2 closed days (even if country unknown)
|
||||
}
|
||||
@@ -180,48 +180,48 @@ class DateLibTest extends CommonClassTest
|
||||
public function testNumOpenDay()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// With same hours - Tuesday/Wednesday jan 2013
|
||||
$date1=dol_mktime(0, 0, 0, 1, 1, 2013, 'gmt'); // tuesday
|
||||
$date2=dol_mktime(0, 0, 0, 1, 2, 2013, 'gmt'); // wednesday
|
||||
$date3=dol_mktime(0, 0, 0, 1, 3, 2013, 'gmt'); // thursday
|
||||
$date1 = dol_mktime(0, 0, 0, 1, 1, 2013, 'gmt'); // tuesday
|
||||
$date2 = dol_mktime(0, 0, 0, 1, 2, 2013, 'gmt'); // wednesday
|
||||
$date3 = dol_mktime(0, 0, 0, 1, 3, 2013, 'gmt'); // thursday
|
||||
|
||||
$result=num_open_day($date1, $date2, 0, 1, 0, 'FR');
|
||||
$result = num_open_day($date1, $date2, 0, 1, 0, 'FR');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(1, $result, 'NumOpenDay Tuesday 1 - Wednesday 2 jan 2013 for FR'); // 1 opened days (country france)
|
||||
|
||||
$result=num_open_day($date1, $date2, 0, 1, 0, 'XX');
|
||||
$result = num_open_day($date1, $date2, 0, 1, 0, 'XX');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(1, $result, 'NumOpenDay Tuesday 1 - Wednesday 2 jan 2013 for XX'); // 1 opened days (country unknown)
|
||||
|
||||
$result=num_open_day($date2, $date3, 0, 1, 0, 'FR');
|
||||
$result = num_open_day($date2, $date3, 0, 1, 0, 'FR');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(2, $result, 'NumOpenDay Wednesday 2 - Thursday 3 jan 2013 for FR'); // 2 opened days
|
||||
|
||||
// With same hours - Friday/Sunday jan 2013
|
||||
$date1=dol_mktime(0, 0, 0, 1, 4, 2013, 'gmt'); // friday
|
||||
$date2=dol_mktime(0, 0, 0, 1, 6, 2013, 'gmt'); // sunday
|
||||
$date1 = dol_mktime(0, 0, 0, 1, 4, 2013, 'gmt'); // friday
|
||||
$date2 = dol_mktime(0, 0, 0, 1, 6, 2013, 'gmt'); // sunday
|
||||
|
||||
$result=num_open_day($date1, $date2, 0, 1, 0, 'FR');
|
||||
$result = num_open_day($date1, $date2, 0, 1, 0, 'FR');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(1, $result, 'NumOpenDay for FR'); // 1 opened day, 2 closed
|
||||
|
||||
$result=num_open_day($date1, $date2, 'XX', 1);
|
||||
$result = num_open_day($date1, $date2, 'XX', 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(1, $result, 'NumOpenDay for XX'); // 1 opened day, 2 closes (even if country unknown)
|
||||
|
||||
// Test option MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY and MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY
|
||||
$conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY = 0;
|
||||
$result=num_open_day($date1, $date2, 0, 1, 0, 'FR');
|
||||
$result = num_open_day($date1, $date2, 0, 1, 0, 'FR');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(2, $result, 'NumOpenDay for FR when saturday is a working day'); //2 opened day, 1 closed
|
||||
|
||||
$conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY = 0;
|
||||
$result=num_open_day($date1, $date2, 'XX', 1);
|
||||
$result = num_open_day($date1, $date2, 'XX', 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(3, $result, 'NumOpenDay for XX when saturday + sunday are working days'); // 3 opened day, 0 closes (even if country unknown)
|
||||
}
|
||||
@@ -234,12 +234,12 @@ class DateLibTest extends CommonClassTest
|
||||
public function testConvertTime2Seconds()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=convertTime2Seconds(1, 1, 2);
|
||||
$result = convertTime2Seconds(1, 1, 2);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(3662, $result);
|
||||
|
||||
@@ -254,16 +254,16 @@ class DateLibTest extends CommonClassTest
|
||||
public function testConvertSecondToTime()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=convertSecondToTime(0, 'all', 86400);
|
||||
$result = convertSecondToTime(0, 'all', 86400);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('0', $result);
|
||||
|
||||
$result=convertSecondToTime(86400, 'all', 86400);
|
||||
$result = convertSecondToTime(86400, 'all', 86400);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertSame('1 '.$langs->trans("d"), $result);
|
||||
|
||||
@@ -278,63 +278,63 @@ class DateLibTest extends CommonClassTest
|
||||
public function testDolPrintDate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// Check %Y-%m-%d %H:%M:%S format
|
||||
$result=dol_print_date('1970-01-01', '%Y-%m-%d %H:%M:%S', true); // A case for compatibility check
|
||||
$result = dol_print_date('1970-01-01', '%Y-%m-%d %H:%M:%S', true); // A case for compatibility check
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1970-01-01 00:00:00', $result);
|
||||
|
||||
|
||||
// Check %Y-%m-%d %H:%M:%S format
|
||||
$result=dol_print_date(0, '%Y-%m-%d %H:%M:%S', true);
|
||||
$result = dol_print_date(0, '%Y-%m-%d %H:%M:%S', true);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1970-01-01 00:00:00', $result);
|
||||
|
||||
// Same with T and Z
|
||||
$result=dol_print_date(0, '%Y-%m-%dT%H:%M:%SZ', true);
|
||||
$result = dol_print_date(0, '%Y-%m-%dT%H:%M:%SZ', true);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1970-01-01T00:00:00Z', $result);
|
||||
|
||||
// Check %Y-%m-%d %H:%M:%S format
|
||||
$result=dol_print_date(16725225600, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/
|
||||
$result = dol_print_date(16725225600, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('2500-01-01 00:00:00', $result);
|
||||
|
||||
// Check %Y-%m-%d %H:%M:%S format
|
||||
$result=dol_print_date(-1830384000, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/
|
||||
$result = dol_print_date(-1830384000, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1912-01-01 00:00:00', $result); // dol_print_date use TZ (good) but epoch converter does not use it.
|
||||
|
||||
// Check %Y-%m-%d %H:%M:%S format
|
||||
$result=dol_print_date(-11676096000, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/
|
||||
$result = dol_print_date(-11676096000, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1600-01-01 00:00:00', $result);
|
||||
|
||||
// test with negative timezone
|
||||
$result=dol_print_date(-1, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/
|
||||
$result = dol_print_date(-1, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1969-12-31 23:59:59', $result);
|
||||
|
||||
// Check dayhour format for fr_FR
|
||||
$outputlangs=new Translate('', $conf);
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang('fr_FR');
|
||||
$outputlangs->load("main");
|
||||
|
||||
$result=dol_print_date(0+24*3600, 'dayhour', true, $outputlangs);
|
||||
$result = dol_print_date(0 + 24 * 3600, 'dayhour', true, $outputlangs);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('02/01/1970 00:00', $result);
|
||||
|
||||
// Check %a and %b format for fr_FR
|
||||
$result=dol_print_date(0, '%a %b %B', true, $outputlangs);
|
||||
$result = dol_print_date(0, '%a %b %B', true, $outputlangs);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('Jeu Jan. Janvier', $result);
|
||||
|
||||
|
||||
$result=dol_print_date(1619388000, '%Y-%m-%d %a', 'gmt', $outputlangs);
|
||||
$result = dol_print_date(1619388000, '%Y-%m-%d %a', 'gmt', $outputlangs);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('2021-04-25 Dim', $result);
|
||||
|
||||
@@ -345,16 +345,16 @@ class DateLibTest extends CommonClassTest
|
||||
*/
|
||||
|
||||
// Check day format for en_US
|
||||
$outputlangs=new Translate('', $conf);
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang('en_US');
|
||||
$outputlangs->load("main");
|
||||
|
||||
$result=dol_print_date(0+24*3600, 'day', true, $outputlangs);
|
||||
$result = dol_print_date(0 + 24 * 3600, 'day', true, $outputlangs);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('01/02/1970', $result);
|
||||
|
||||
// Check %a and %b format for en_US
|
||||
$result=dol_print_date(0, '%a %b %B', true, $outputlangs);
|
||||
$result = dol_print_date(0, '%a %b %B', true, $outputlangs);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('Thu Jan January', $result);
|
||||
|
||||
@@ -369,17 +369,17 @@ class DateLibTest extends CommonClassTest
|
||||
public function testDolTimePlusDuree()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// Check dayhour format for fr_FR
|
||||
$outputlangs=new Translate('', $conf);
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang('fr_FR');
|
||||
$outputlangs->load("main");
|
||||
|
||||
$result=dol_print_date(dol_time_plus_duree(dol_time_plus_duree(dol_time_plus_duree(0, 1, 'm'), 1, 'y'), 1, 'd'), 'dayhour', true, $outputlangs);
|
||||
$result = dol_print_date(dol_time_plus_duree(dol_time_plus_duree(dol_time_plus_duree(0, 1, 'm'), 1, 'y'), 1, 'd'), 'dayhour', true, $outputlangs);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('02/02/1971 00:00', $result);
|
||||
|
||||
@@ -394,33 +394,33 @@ class DateLibTest extends CommonClassTest
|
||||
public function testDolStringToTime()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$stime='19700102';
|
||||
$result=dol_stringtotime($stime);
|
||||
$stime = '19700102';
|
||||
$result = dol_stringtotime($stime);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(86400, $result);
|
||||
|
||||
$stime='1970-01-01T02:00:00Z';
|
||||
$result=dol_stringtotime($stime);
|
||||
$stime = '1970-01-01T02:00:00Z';
|
||||
$result = dol_stringtotime($stime);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(7200, $result);
|
||||
|
||||
$stime='1970-01-01 02:00:00';
|
||||
$result=dol_stringtotime($stime);
|
||||
$stime = '1970-01-01 02:00:00';
|
||||
$result = dol_stringtotime($stime);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(7200, $result);
|
||||
|
||||
$stime='19700101T020000Z';
|
||||
$result=dol_stringtotime($stime);
|
||||
$stime = '19700101T020000Z';
|
||||
$result = dol_stringtotime($stime);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(7200, $result);
|
||||
|
||||
$stime='19700101020000';
|
||||
$result=dol_stringtotime($stime);
|
||||
$stime = '19700101020000';
|
||||
$result = dol_stringtotime($stime);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(7200, $result);
|
||||
|
||||
@@ -436,16 +436,16 @@ class DateLibTest extends CommonClassTest
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$day=3;
|
||||
$month=2;
|
||||
$year=2015;
|
||||
$day = 3;
|
||||
$month = 2;
|
||||
$year = 2015;
|
||||
$conf->global->MAIN_START_WEEK = 1; // start on monday
|
||||
$prev = dol_get_first_day_week($day, $month, $year);
|
||||
$this->assertEquals(2, (int) $prev['first_day']); // monday for month 2, year 2014 is the 2
|
||||
|
||||
$day=3;
|
||||
$month=2;
|
||||
$year=2015;
|
||||
$day = 3;
|
||||
$month = 2;
|
||||
$year = 2015;
|
||||
$conf->global->MAIN_START_WEEK = 0; // start on sunday
|
||||
$prev = dol_get_first_day_week($day, $month, $year);
|
||||
$this->assertEquals(1, (int) $prev['first_day']); // sunday for month 2, year 2015 is the 1st
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -82,68 +82,68 @@ class DateLibTzFranceTest extends CommonClassTest
|
||||
public function testDolPrintDateTzFrance()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// Check %Y-%m-%d %H:%M:%S format
|
||||
$result=dol_print_date(0, '%Y-%m-%d %H:%M:%S', false);
|
||||
$result = dol_print_date(0, '%Y-%m-%d %H:%M:%S', false);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1970-01-01 01:00:00', $result);
|
||||
|
||||
// Check %Y-%m-%d %H:%M:%S format
|
||||
$result=dol_print_date(16725225600, '%Y-%m-%d %H:%M:%S', false);
|
||||
$result = dol_print_date(16725225600, '%Y-%m-%d %H:%M:%S', false);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('2500-01-01 01:00:00', $result);
|
||||
|
||||
// Check %Y-%m-%d %H:%M:%S format
|
||||
$result=dol_print_date(-1830384000, '%Y-%m-%d %H:%M:%S', false); // http://www.epochconverter.com/
|
||||
$result = dol_print_date(-1830384000, '%Y-%m-%d %H:%M:%S', false); // http://www.epochconverter.com/
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1912-01-01 01:00:00', $result); // dol_print_date use a timezone, not epoch converter as it did not exists this year
|
||||
|
||||
// Specific cas during war
|
||||
|
||||
// 1940, no timezone
|
||||
$result=dol_print_date(-946771200, '%Y-%m-%d %H:%M:%S', false); // http://www.epochconverter.com/
|
||||
$result = dol_print_date(-946771200, '%Y-%m-%d %H:%M:%S', false); // http://www.epochconverter.com/
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1940-01-01 01:00:00', $result); // dol_print_date use a modern timezone, not epoch converter as it did not exists this year
|
||||
|
||||
// 1941, timezone is added by germany to +2 (same for 1942)
|
||||
$result=dol_print_date(-915148800, '%Y-%m-%d %H:%M:%S', false); // http://www.epochconverter.com/
|
||||
$result = dol_print_date(-915148800, '%Y-%m-%d %H:%M:%S', false); // http://www.epochconverter.com/
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1941-01-01 01:00:00', $result); // dol_print_date use a modern timezone, epoch converter use historic timezone
|
||||
|
||||
// 1943, timezone is +1
|
||||
$result=dol_print_date(-852076800, '%Y-%m-%d %H:%M:%S', false); // http://www.epochconverter.com/
|
||||
$result = dol_print_date(-852076800, '%Y-%m-%d %H:%M:%S', false); // http://www.epochconverter.com/
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1943-01-01 01:00:00', $result);
|
||||
|
||||
// test with negative timezone
|
||||
$result=dol_print_date(-1, '%Y-%m-%d %H:%M:%S', false); // http://www.epochconverter.com/
|
||||
$result = dol_print_date(-1, '%Y-%m-%d %H:%M:%S', false); // http://www.epochconverter.com/
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1970-01-01 00:59:59', $result);
|
||||
|
||||
// Check dayhour format for fr_FR
|
||||
$outputlangs=new Translate('', $conf);
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang('fr_FR');
|
||||
$outputlangs->load("main");
|
||||
|
||||
$result=dol_print_date(0+24*3600, 'dayhour', false, $outputlangs);
|
||||
$result = dol_print_date(0 + 24 * 3600, 'dayhour', false, $outputlangs);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('02/01/1970 01:00', $result);
|
||||
|
||||
// Check day format for en_US
|
||||
$outputlangs=new Translate('', $conf);
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang('en_US');
|
||||
$outputlangs->load("main");
|
||||
|
||||
$result=dol_print_date(0+24*3600, 'day', false, $outputlangs);
|
||||
$result = dol_print_date(0 + 24 * 3600, 'day', false, $outputlangs);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('01/02/1970', $result);
|
||||
|
||||
// Check %a and %b format for en_US
|
||||
$result=dol_print_date(0, '%a %b', false, $outputlangs);
|
||||
$result = dol_print_date(0, '%a %b', false, $outputlangs);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('Thu Jan', $result);
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,20 +56,20 @@ class DiscountTest extends CommonClassTest
|
||||
public function testDiscountCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$soc = new Societe($db);
|
||||
$soc->name = "CommandeTest Unittest";
|
||||
$socid = $soc->create($user);
|
||||
$this->assertLessThan($socid, 0, $soc->errorsToString());
|
||||
|
||||
$localobject=new DiscountAbsolute($db);
|
||||
$localobject = new DiscountAbsolute($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fk_soc = $socid;
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -88,13 +88,13 @@ class DiscountTest extends CommonClassTest
|
||||
public function testDiscountFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new DiscountAbsolute($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new DiscountAbsolute($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
@@ -113,14 +113,14 @@ class DiscountTest extends CommonClassTest
|
||||
public function testDiscountDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new DiscountAbsolute($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new DiscountAbsolute($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,10 +56,10 @@ class DoliDBTest extends CommonClassTest
|
||||
public function testDDLUpdateField()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
print __METHOD__.' db->type = '.$db->type."\n";
|
||||
|
||||
@@ -74,14 +74,14 @@ class DoliDBTest extends CommonClassTest
|
||||
}
|
||||
|
||||
// Set new field
|
||||
$field_desc = array('type'=>'varchar', 'value'=>'17', 'null'=>'NOT NULL');
|
||||
$field_desc = array('type' => 'varchar', 'value' => '17', 'null' => 'NOT NULL');
|
||||
|
||||
$result = $db->DDLUpdateField($db->prefix().'c_paper_format', 'code', $field_desc);
|
||||
$this->assertEquals(1, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
// TODO Use $savtype and $savnull instead of hard coded
|
||||
$field_desc = array('type'=>'varchar', 'value'=>'16', 'null'=>'NOT NULL');
|
||||
$field_desc = array('type' => 'varchar', 'value' => '16', 'null' => 'NOT NULL');
|
||||
|
||||
$result = $db->DDLUpdateField($db->prefix().'c_paper_format', 'code', $field_desc);
|
||||
$this->assertEquals(1, $result);
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
|
||||
@@ -58,22 +58,22 @@ class EmailCollectorTest extends CommonClassTest
|
||||
public function testEmailCollectorCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$langs->load("main");
|
||||
|
||||
// Create supplier order with a too low quantity
|
||||
$localobject=new EmailCollector($db);
|
||||
$localobject = new EmailCollector($db);
|
||||
$localobject->initAsSpecimen(); // Init a specimen with lines
|
||||
|
||||
$this->filters = array();
|
||||
|
||||
$this->actions = array();
|
||||
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result, "Error on test EmailCollector create: ".$localobject->error.' '.join(',', $localobject->errors));
|
||||
|
||||
@@ -93,13 +93,13 @@ class EmailCollectorTest extends CommonClassTest
|
||||
public function testEmailCollectorFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new EmailCollector($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new EmailCollector($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -118,12 +118,12 @@ class EmailCollectorTest extends CommonClassTest
|
||||
public function testEmailCollectorCollect($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->getConnectStringIMAP();
|
||||
$result = $localobject->getConnectStringIMAP();
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertEquals('{localhost:993/service=imap/ssl/novalidate-cert}', $result, 'Error in getConnectStringIMAP '.$localobject->error);
|
||||
|
||||
@@ -142,14 +142,14 @@ class EmailCollectorTest extends CommonClassTest
|
||||
public function testEmailCollectorDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new EmailCollector($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new EmailCollector($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,14 +56,14 @@ class EntrepotTest extends CommonClassTest
|
||||
public function testEntrepotCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Entrepot($db);
|
||||
$localobject = new Entrepot($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
@@ -83,13 +83,13 @@ class EntrepotTest extends CommonClassTest
|
||||
public function testEntrepotFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Entrepot($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Entrepot($db);
|
||||
$result = $localobject->fetch($id);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -108,13 +108,13 @@ class EntrepotTest extends CommonClassTest
|
||||
public function testEntrepotUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->note='New note after update';
|
||||
$result=$localobject->update($localobject->id, $user);
|
||||
$localobject->note = 'New note after update';
|
||||
$result = $localobject->update($localobject->id, $user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -133,10 +133,10 @@ class EntrepotTest extends CommonClassTest
|
||||
public function testEntrepotOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result = $localobject->get_full_arbo();
|
||||
$this->assertEquals('WAREHOUSE SPECIMEN', $result);
|
||||
@@ -156,15 +156,15 @@ class EntrepotTest extends CommonClassTest
|
||||
public function testEntrepotDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Entrepot($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Entrepot($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$result=$localobject->delete($user);
|
||||
$result = $localobject->delete($user);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, $localobject->errorsToString());
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
|
||||
@@ -57,32 +57,32 @@ class ExpenseReportTest extends CommonClassTest
|
||||
public function testExpenseReportCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// Create supplier order with a too low quantity
|
||||
$localobject=new ExpenseReport($db);
|
||||
$localobject = new ExpenseReport($db);
|
||||
$localobject->initAsSpecimen(); // Init a specimen with lines
|
||||
$localobject->status = 0;
|
||||
$localobject->fk_statut = 0;
|
||||
$localobject->date_fin = null; // Force bad value
|
||||
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(-1, $result, "Error on test ExpenseReport create 1 : ".$localobject->error); // must be -1 because of missing mandatory fields
|
||||
|
||||
$sql="DELETE FROM ".MAIN_DB_PREFIX."expensereport where ref=''";
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expensereport where ref=''";
|
||||
$db->query($sql);
|
||||
|
||||
// Create supplier order
|
||||
$localobject2=new ExpenseReport($db);
|
||||
$localobject2 = new ExpenseReport($db);
|
||||
$localobject2->initAsSpecimen(); // Init a specimen with lines
|
||||
$localobject2->status = 0;
|
||||
$localobject2->fk_statut = 0;
|
||||
|
||||
$result=$localobject2->create($user);
|
||||
$result = $localobject2->create($user);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(0, $result, "Error on test ExpenseReport create 2 : ".$localobject2->error);
|
||||
|
||||
@@ -102,13 +102,13 @@ class ExpenseReportTest extends CommonClassTest
|
||||
public function testExpenseReportFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new ExpenseReport($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new ExpenseReport($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -127,12 +127,12 @@ class ExpenseReportTest extends CommonClassTest
|
||||
public function testExpenseReportValid($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->setValidate($user);
|
||||
$result = $localobject->setValidate($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -151,12 +151,12 @@ class ExpenseReportTest extends CommonClassTest
|
||||
public function testExpenseReportApprove($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->setApproved($user);
|
||||
$result = $localobject->setApproved($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -175,12 +175,12 @@ class ExpenseReportTest extends CommonClassTest
|
||||
public function testExpenseReportCancel($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->set_cancel($user, 'Because...');
|
||||
$result = $localobject->set_cancel($user, 'Because...');
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -199,12 +199,12 @@ class ExpenseReportTest extends CommonClassTest
|
||||
public function testExpenseReportOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->getSumPayments();
|
||||
$result = $localobject->getSumPayments();
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(0, $result);
|
||||
|
||||
@@ -223,14 +223,14 @@ class ExpenseReportTest extends CommonClassTest
|
||||
public function testExpenseReportDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new ExpenseReport($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new ExpenseReport($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
|
||||
@@ -82,7 +82,7 @@ class ExportTest extends CommonClassTest
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
$model='csvutf8';
|
||||
$model = 'csvutf8';
|
||||
|
||||
$conf->global->EXPORT_CSV_SEPARATOR_TO_USE = ',';
|
||||
print 'EXPORT_CSV_SEPARATOR_TO_USE = ' . getDolGlobalString('EXPORT_CSV_SEPARATOR_TO_USE');
|
||||
@@ -97,31 +97,31 @@ class ExportTest extends CommonClassTest
|
||||
// First test without option USE_STRICT_CSV_RULES
|
||||
unset($conf->global->USE_STRICT_CSV_RULES);
|
||||
|
||||
$valtotest='A simple string';
|
||||
$valtotest = 'A simple string';
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, 'A simple string');
|
||||
|
||||
$valtotest='A string with , and ; inside';
|
||||
$valtotest = 'A string with , and ; inside';
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, '"A string with , and ; inside"', 'Error in csvClean for '.$file);
|
||||
|
||||
$valtotest='A string with " inside';
|
||||
$valtotest = 'A string with " inside';
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, '"A string with "" inside"');
|
||||
|
||||
$valtotest='A string with " inside and '."\r\n".' carriage returns';
|
||||
$valtotest = 'A string with " inside and '."\r\n".' carriage returns';
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, '"A string with "" inside and \n carriage returns"');
|
||||
|
||||
$valtotest='A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n";
|
||||
$valtotest = 'A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n";
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -130,31 +130,31 @@ class ExportTest extends CommonClassTest
|
||||
// Same tests with strict mode
|
||||
$conf->global->USE_STRICT_CSV_RULES = 1;
|
||||
|
||||
$valtotest='A simple string';
|
||||
$valtotest = 'A simple string';
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, 'A simple string');
|
||||
|
||||
$valtotest='A string with , and ; inside';
|
||||
$valtotest = 'A string with , and ; inside';
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, '"A string with , and ; inside"');
|
||||
|
||||
$valtotest='A string with " inside';
|
||||
$valtotest = 'A string with " inside';
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, '"A string with "" inside"');
|
||||
|
||||
$valtotest='A string with " inside and '."\r\n".' carriage returns';
|
||||
$valtotest = 'A string with " inside and '."\r\n".' carriage returns';
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, "\"A string with \"\" inside and \r\n carriage returns\"");
|
||||
|
||||
$valtotest='A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n";
|
||||
$valtotest = 'A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n";
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -171,7 +171,7 @@ class ExportTest extends CommonClassTest
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
$model='csviso';
|
||||
$model = 'csviso';
|
||||
|
||||
$conf->global->EXPORT_CSV_SEPARATOR_TO_USE = ',';
|
||||
print 'EXPORT_CSV_SEPARATOR_TO_USE = ' . getDolGlobalString('EXPORT_CSV_SEPARATOR_TO_USE');
|
||||
@@ -186,31 +186,31 @@ class ExportTest extends CommonClassTest
|
||||
// First test without option USE_STRICT_CSV_RULES
|
||||
unset($conf->global->USE_STRICT_CSV_RULES);
|
||||
|
||||
$valtotest='A simple string';
|
||||
$valtotest = 'A simple string';
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, 'A simple string');
|
||||
|
||||
$valtotest='A string with , and ; inside';
|
||||
$valtotest = 'A string with , and ; inside';
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, '"A string with , and ; inside"', 'Error in csvClean for '.$file);
|
||||
|
||||
$valtotest='A string with " inside';
|
||||
$valtotest = 'A string with " inside';
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, '"A string with "" inside"');
|
||||
|
||||
$valtotest='A string with " inside and '."\r\n".' carriage returns';
|
||||
$valtotest = 'A string with " inside and '."\r\n".' carriage returns';
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, '"A string with "" inside and \n carriage returns"');
|
||||
|
||||
$valtotest='A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n";
|
||||
$valtotest = 'A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n";
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -219,31 +219,31 @@ class ExportTest extends CommonClassTest
|
||||
// Same tests with strict mode
|
||||
$conf->global->USE_STRICT_CSV_RULES = 1;
|
||||
|
||||
$valtotest='A simple string';
|
||||
$valtotest = 'A simple string';
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, 'A simple string');
|
||||
|
||||
$valtotest='A string with , and ; inside';
|
||||
$valtotest = 'A string with , and ; inside';
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, '"A string with , and ; inside"');
|
||||
|
||||
$valtotest='A string with " inside';
|
||||
$valtotest = 'A string with " inside';
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, '"A string with "" inside"');
|
||||
|
||||
$valtotest='A string with " inside and '."\r\n".' carriage returns';
|
||||
$valtotest = 'A string with " inside and '."\r\n".' carriage returns';
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, "\"A string with \"\" inside and \r\n carriage returns\"");
|
||||
|
||||
$valtotest='A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n";
|
||||
$valtotest = 'A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n";
|
||||
print __METHOD__." valtotest=".$valtotest."\n";
|
||||
$result = $objmodel->csvClean($valtotest, $langs->charset_output);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -262,50 +262,50 @@ class ExportTest extends CommonClassTest
|
||||
|
||||
$sql = "SELECT f.ref as f_ref, f.total_ht as f_total, f.total_tva as f_tva FROM ".MAIN_DB_PREFIX."facture f";
|
||||
|
||||
$objexport=new Export($db);
|
||||
$objexport = new Export($db);
|
||||
//$objexport->load_arrays($user,$datatoexport);
|
||||
|
||||
// Define properties
|
||||
$datatoexport='test';
|
||||
$array_selected = array("f.ref"=>1, "f.total"=>2, "f.tva"=>3);
|
||||
$array_export_fields = array("f.ref"=>"FacNumber", "f.total"=>"FacTotal", "f.tva"=>"FacVat");
|
||||
$array_alias = array("f_ref"=>"ref", "f_total"=>"total", "f_tva"=>"tva");
|
||||
$objexport->array_export_fields[0]=$array_export_fields;
|
||||
$objexport->array_export_alias[0]=$array_alias;
|
||||
$datatoexport = 'test';
|
||||
$array_selected = array("f.ref" => 1, "f.total" => 2, "f.tva" => 3);
|
||||
$array_export_fields = array("f.ref" => "FacNumber", "f.total" => "FacTotal", "f.tva" => "FacVat");
|
||||
$array_alias = array("f_ref" => "ref", "f_total" => "total", "f_tva" => "tva");
|
||||
$objexport->array_export_fields[0] = $array_export_fields;
|
||||
$objexport->array_export_alias[0] = $array_alias;
|
||||
|
||||
dol_mkdir($conf->export->dir_temp);
|
||||
|
||||
$model='csviso';
|
||||
$model = 'csviso';
|
||||
|
||||
// Build export file
|
||||
print "Process build_file for model = ".$model."\n";
|
||||
$result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
|
||||
$result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
|
||||
$expectedresult = 1;
|
||||
$this->assertEquals($expectedresult, $result, 'Error in CSV export');
|
||||
|
||||
$model='csvutf8';
|
||||
$model = 'csvutf8';
|
||||
|
||||
// Build export file
|
||||
print "Process build_file for model = ".$model."\n";
|
||||
$result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
|
||||
$result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
|
||||
$expectedresult = 1;
|
||||
$this->assertEquals($expectedresult, $result, 'Error in CSV export');
|
||||
|
||||
$model='tsv';
|
||||
$model = 'tsv';
|
||||
|
||||
// Build export file
|
||||
print "Process build_file for model = ".$model."\n";
|
||||
$result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
|
||||
$expectedresult=1;
|
||||
$result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
|
||||
$expectedresult = 1;
|
||||
$this->assertEquals($expectedresult, $result, 'Error in TSV export');
|
||||
|
||||
$model='excel2007';
|
||||
$model = 'excel2007';
|
||||
|
||||
// Build export file
|
||||
/* ko on php 7.4 on travis (zip not available) */
|
||||
print "Process build_file for model = ".$model."\n";
|
||||
$result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
|
||||
$expectedresult=1;
|
||||
$result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
|
||||
$expectedresult = 1;
|
||||
$this->assertEquals($expectedresult, $result, 'Error in Excel2007 export');
|
||||
|
||||
return true;
|
||||
@@ -373,36 +373,36 @@ class ExportTest extends CommonClassTest
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
$model='csviso';
|
||||
$model = 'csviso';
|
||||
|
||||
$filterdatatoexport='';
|
||||
$filterdatatoexport = '';
|
||||
//$filterdatatoexport='';
|
||||
//$array_selected = array("s.rowid"=>1, "s.nom"=>2); // Must be fields found into declaration of dataset
|
||||
|
||||
// Load properties of arrays to make export
|
||||
$objexport=new Export($db);
|
||||
$result=$objexport->load_arrays($user, $filterdatatoexport); // This load ->array_export_xxx properties for datatoexport
|
||||
$objexport = new Export($db);
|
||||
$result = $objexport->load_arrays($user, $filterdatatoexport); // This load ->array_export_xxx properties for datatoexport
|
||||
|
||||
// Loop on each dataset
|
||||
foreach ($objexport->array_export_code as $key => $datatoexport) {
|
||||
$exportfile=$conf->export->dir_temp.'/'.$user->id.'/export_'.$datatoexport.'.csv';
|
||||
$exportfile = $conf->export->dir_temp.'/'.$user->id.'/export_'.$datatoexport.'.csv';
|
||||
print "Process export for dataset ".$datatoexport." into ".$exportfile."\n";
|
||||
dol_delete_file($exportfile);
|
||||
|
||||
// Generate $array_selected
|
||||
$i=0;
|
||||
$array_selected=array();
|
||||
$i = 0;
|
||||
$array_selected = array();
|
||||
foreach ($objexport->array_export_fields[$key] as $key => $val) {
|
||||
$array_selected[$key]=$i++;
|
||||
$array_selected[$key] = $i++;
|
||||
}
|
||||
//var_dump($array_selected);
|
||||
|
||||
// Build export file
|
||||
$sql = "";
|
||||
$result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
|
||||
$result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
|
||||
$expectedresult = 1;
|
||||
$this->assertEquals($expectedresult, $result, "Call build_file() to export ".$exportfile.' failed: '.$objexport->error);
|
||||
$result=dol_is_file($exportfile);
|
||||
$result = dol_is_file($exportfile);
|
||||
$this->assertTrue($result, 'File '.$exportfile.' not found');
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -57,14 +57,14 @@ class FactureFournisseurTest extends CommonClassTest
|
||||
public function testFactureFournisseurCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new FactureFournisseur($db);
|
||||
$localobject = new FactureFournisseur($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
$this->assertLessThan($result, 0, $localobject->errorsToString());
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -83,13 +83,13 @@ class FactureFournisseurTest extends CommonClassTest
|
||||
public function testFactureFournisseurFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new FactureFournisseur($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new FactureFournisseur($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0, $localobject->errorsToString());
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
@@ -108,13 +108,13 @@ class FactureFournisseurTest extends CommonClassTest
|
||||
public function testFactureFournisseurUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->note='New note after update';
|
||||
$result=$localobject->update($user);
|
||||
$localobject->note = 'New note after update';
|
||||
$result = $localobject->update($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, $localobject->errorsToString());
|
||||
@@ -133,12 +133,12 @@ class FactureFournisseurTest extends CommonClassTest
|
||||
public function testFactureFournisseurValid($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->validate($user);
|
||||
$result = $localobject->validate($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertLessThan($result, 0, $localobject->errorsToString());
|
||||
@@ -157,10 +157,10 @@ class FactureFournisseurTest extends CommonClassTest
|
||||
public function testFactureFournisseurOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
/*$result=$localobject->setstatus(0);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
@@ -186,14 +186,14 @@ class FactureFournisseurTest extends CommonClassTest
|
||||
public function testFactureFournisseurDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new FactureFournisseur($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new FactureFournisseur($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, $localobject->errorsToString());
|
||||
|
||||
@@ -37,7 +37,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -58,18 +58,18 @@ class FactureRecTest extends CommonClassTest
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobjectinv=new Facture($db);
|
||||
$localobjectinv = new Facture($db);
|
||||
$localobjectinv->initAsSpecimen();
|
||||
$result = $localobjectinv->create($user);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
$localobject=new FactureRec($db);
|
||||
$localobject = new FactureRec($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$result = $localobject->create($user, $localobjectinv->id);
|
||||
|
||||
@@ -91,12 +91,12 @@ class FactureRecTest extends CommonClassTest
|
||||
public function testFactureRecFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new FactureRec($db);
|
||||
$localobject = new FactureRec($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -114,7 +114,7 @@ class FactureRecTest extends CommonClassTest
|
||||
*/
|
||||
public function changeProperties(&$localobject)
|
||||
{
|
||||
$localobject->note_private='New note';
|
||||
$localobject->note_private = 'New note';
|
||||
//$localobject->note='New note after update';
|
||||
}
|
||||
|
||||
@@ -129,23 +129,23 @@ class FactureRecTest extends CommonClassTest
|
||||
*/
|
||||
public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id'))
|
||||
{
|
||||
$retAr=array();
|
||||
$retAr = array();
|
||||
|
||||
if (get_class($oA) !== get_class($oB)) {
|
||||
$retAr[]="Supplied objects are not of same class.";
|
||||
$retAr[] = "Supplied objects are not of same class.";
|
||||
} else {
|
||||
$oVarsA=get_object_vars($oA);
|
||||
$oVarsB=get_object_vars($oB);
|
||||
$aKeys=array_keys($oVarsA);
|
||||
$oVarsA = get_object_vars($oA);
|
||||
$oVarsB = get_object_vars($oB);
|
||||
$aKeys = array_keys($oVarsA);
|
||||
foreach ($aKeys as $sKey) {
|
||||
if (in_array($sKey, $fieldstoignorearray)) {
|
||||
continue;
|
||||
}
|
||||
if (! $ignoretype && ($oVarsA[$sKey] !== $oVarsB[$sKey])) {
|
||||
$retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
|
||||
$retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
|
||||
}
|
||||
if ($ignoretype && ($oVarsA[$sKey] != $oVarsB[$sKey])) {
|
||||
$retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
|
||||
$retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -81,14 +81,14 @@ class FactureTest extends CommonClassTest
|
||||
public function testFactureCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
return $result;
|
||||
@@ -106,13 +106,13 @@ class FactureTest extends CommonClassTest
|
||||
public function testFactureFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Facture($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
@@ -131,13 +131,13 @@ class FactureTest extends CommonClassTest
|
||||
public function testFactureUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$this->changeProperties($localobject);
|
||||
$result=$localobject->update($user);
|
||||
$result = $localobject->update($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -156,18 +156,18 @@ class FactureTest extends CommonClassTest
|
||||
public function testFactureValid($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->validate($user);
|
||||
$result = $localobject->validate($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
// Test everything are still same than specimen
|
||||
$newlocalobject=new Facture($db);
|
||||
$newlocalobject = new Facture($db);
|
||||
$newlocalobject->initAsSpecimen();
|
||||
$this->changeProperties($newlocalobject);
|
||||
|
||||
@@ -205,10 +205,10 @@ class FactureTest extends CommonClassTest
|
||||
public function testFactureOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
/*$result=$localobject->setstatus(0);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
@@ -219,7 +219,7 @@ class FactureTest extends CommonClassTest
|
||||
print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n";
|
||||
$this->assertNotEquals($localobject->date_creation, '');
|
||||
|
||||
$result=$localobject->demande_prelevement($user);
|
||||
$result = $localobject->demande_prelevement($user);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -238,43 +238,43 @@ class FactureTest extends CommonClassTest
|
||||
public function testFactureDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// Force default setup
|
||||
unset($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED);
|
||||
unset($conf->global->INVOICE_CAN_NEVER_BE_REMOVED);
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Facture($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
// Create another invoice and validate it after $localobject
|
||||
$localobject2=new Facture($db);
|
||||
$result=$localobject2->initAsSpecimen();
|
||||
$result=$localobject2->create($user);
|
||||
$result=$localobject2->validate($user);
|
||||
$localobject2 = new Facture($db);
|
||||
$result = $localobject2->initAsSpecimen();
|
||||
$result = $localobject2->create($user);
|
||||
$result = $localobject2->validate($user);
|
||||
print 'Invoice $localobject ref = '.$localobject->ref."\n";
|
||||
print 'Invoice $localobject2 created with ref = '.$localobject2->ref."\n";
|
||||
|
||||
$conf->global->INVOICE_CAN_NEVER_BE_REMOVED = 1;
|
||||
|
||||
$result=$localobject2->delete($user); // Deletion is KO, option INVOICE_CAN_NEVER_BE_REMOVED is on
|
||||
$result = $localobject2->delete($user); // Deletion is KO, option INVOICE_CAN_NEVER_BE_REMOVED is on
|
||||
print __METHOD__." id=".$localobject2->id." ref=".$localobject2->ref." result=".$result."\n";
|
||||
$this->assertEquals(0, $result, 'Deletion should fail, option INVOICE_CAN_NEVER_BE_REMOVED is on');
|
||||
|
||||
unset($conf->global->INVOICE_CAN_NEVER_BE_REMOVED);
|
||||
|
||||
$result=$localobject->delete($user); // Deletion is KO, it is not last invoice
|
||||
$result = $localobject->delete($user); // Deletion is KO, it is not last invoice
|
||||
print __METHOD__." id=".$localobject->id." ref=".$localobject->ref." result=".$result."\n";
|
||||
$this->assertEquals(0, $result, 'Deletion should fail, it is not last invoice');
|
||||
|
||||
$result=$localobject2->delete($user); // Deletion is OK, it is last invoice
|
||||
$result = $localobject2->delete($user); // Deletion is OK, it is last invoice
|
||||
print __METHOD__." id=".$localobject2->id." ref=".$localobject2->ref." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result, 'Deletion should work, it is last invoice');
|
||||
|
||||
$result=$localobject->delete($user); // Deletion is KO, it is not last invoice
|
||||
$result = $localobject->delete($user); // Deletion is KO, it is not last invoice
|
||||
print __METHOD__." id=".$localobject->id." ref=".$localobject->ref." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result, 'Deletion should work, it is again last invoice');
|
||||
|
||||
@@ -289,7 +289,7 @@ class FactureTest extends CommonClassTest
|
||||
*/
|
||||
public function changeProperties(&$localobject)
|
||||
{
|
||||
$localobject->note_private='New note';
|
||||
$localobject->note_private = 'New note';
|
||||
//$localobject->note='New note after update';
|
||||
}
|
||||
|
||||
@@ -304,23 +304,23 @@ class FactureTest extends CommonClassTest
|
||||
*/
|
||||
public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id'))
|
||||
{
|
||||
$retAr=array();
|
||||
$retAr = array();
|
||||
|
||||
if (get_class($oA) !== get_class($oB)) {
|
||||
$retAr[]="Supplied objects are not of same class.";
|
||||
$retAr[] = "Supplied objects are not of same class.";
|
||||
} else {
|
||||
$oVarsA=get_object_vars($oA);
|
||||
$oVarsB=get_object_vars($oB);
|
||||
$aKeys=array_keys($oVarsA);
|
||||
$oVarsA = get_object_vars($oA);
|
||||
$oVarsB = get_object_vars($oB);
|
||||
$aKeys = array_keys($oVarsA);
|
||||
foreach ($aKeys as $sKey) {
|
||||
if (in_array($sKey, $fieldstoignorearray)) {
|
||||
continue;
|
||||
}
|
||||
if (! $ignoretype && ($oVarsA[$sKey] !== $oVarsB[$sKey])) {
|
||||
$retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
|
||||
$retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
|
||||
}
|
||||
if ($ignoretype && ($oVarsA[$sKey] != $oVarsB[$sKey])) {
|
||||
$retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
|
||||
$retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,27 +56,27 @@ class FactureTestRounding extends CommonClassTest
|
||||
public function testFactureRoundingCreate1()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0;
|
||||
$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0;
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->lines=array();
|
||||
$localobject->lines = array();
|
||||
unset($localobject->total_ht);
|
||||
unset($localobject->total_ttc);
|
||||
unset($localobject->total_tva);
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
// Add two lines
|
||||
for ($i=0; $i<2; $i++) {
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
$localobject->addline('Description '.$i, 1.24, 1, 10);
|
||||
}
|
||||
|
||||
$newlocalobject=new Facture($db);
|
||||
$newlocalobject = new Facture($db);
|
||||
$newlocalobject->fetch($result);
|
||||
//var_dump($newlocalobject);
|
||||
|
||||
@@ -98,27 +98,27 @@ class FactureTestRounding extends CommonClassTest
|
||||
public function testFactureRoundingCreate2()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0;
|
||||
$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0;
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->lines=array();
|
||||
$localobject->lines = array();
|
||||
unset($localobject->total_ht);
|
||||
unset($localobject->total_ttc);
|
||||
unset($localobject->total_vat);
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
// Add two lines
|
||||
for ($i=0; $i<2; $i++) {
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
$localobject->addline('Description '.$i, 1.24, 1, 10);
|
||||
}
|
||||
|
||||
$newlocalobject=new Facture($db);
|
||||
$newlocalobject = new Facture($db);
|
||||
$newlocalobject->fetch($result);
|
||||
//var_dump($newlocalobject);
|
||||
|
||||
@@ -137,17 +137,17 @@ class FactureTestRounding extends CommonClassTest
|
||||
public function testFactureAddLine1()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0
|
||||
$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0;
|
||||
$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0;
|
||||
|
||||
$localobject1a=new Facture($db);
|
||||
$localobject1a = new Facture($db);
|
||||
$localobject1a->initAsSpecimen('nolines');
|
||||
$facid=$localobject1a->create($user);
|
||||
$facid = $localobject1a->create($user);
|
||||
$localobject1a->addline('Line 1', 6.36, 15, 21); // This include update_price
|
||||
print __METHOD__." id=".$facid." total_ttc=".$localobject1a->total_ttc."\n";
|
||||
$this->assertEquals(95.40, $localobject1a->total_ht);
|
||||
@@ -155,11 +155,11 @@ class FactureTestRounding extends CommonClassTest
|
||||
$this->assertEquals(115.43, $localobject1a->total_ttc);
|
||||
|
||||
// With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1
|
||||
$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1;
|
||||
$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1;
|
||||
|
||||
$localobject1b=new Facture($db);
|
||||
$localobject1b = new Facture($db);
|
||||
$localobject1b->initAsSpecimen('nolines');
|
||||
$facid=$localobject1b->create($user);
|
||||
$facid = $localobject1b->create($user);
|
||||
$localobject1b->addline('Line 1', 6.36, 15, 21); // This include update_price
|
||||
print __METHOD__." id=".$facid." total_ttc=".$localobject1b->total_ttc."\n";
|
||||
$this->assertEquals(95.40, $localobject1b->total_ht, 'testFactureAddLine1 total_ht');
|
||||
@@ -178,17 +178,17 @@ class FactureTestRounding extends CommonClassTest
|
||||
public function testFactureAddLine2()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0
|
||||
$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0;
|
||||
$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0;
|
||||
|
||||
$localobject2=new Facture($db);
|
||||
$localobject2 = new Facture($db);
|
||||
$localobject2->initAsSpecimen('nolines');
|
||||
$facid=$localobject2->create($user);
|
||||
$facid = $localobject2->create($user);
|
||||
$localobject2->addline('Line 1', 6.36, 5, 21);
|
||||
$localobject2->addline('Line 2', 6.36, 5, 21);
|
||||
$localobject2->addline('Line 3', 6.36, 5, 21);
|
||||
@@ -198,11 +198,11 @@ class FactureTestRounding extends CommonClassTest
|
||||
$this->assertEquals(115.44, $localobject2->total_ttc);
|
||||
|
||||
// With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1
|
||||
$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1;
|
||||
$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1;
|
||||
|
||||
$localobject2=new Facture($db);
|
||||
$localobject2 = new Facture($db);
|
||||
$localobject2->initAsSpecimen('nolines');
|
||||
$facid=$localobject2->create($user);
|
||||
$facid = $localobject2->create($user);
|
||||
$localobject2->addline('Line 1', 6.36, 5, 21);
|
||||
$localobject2->addline('Line 2', 6.36, 5, 21);
|
||||
$localobject2->addline('Line 3', 6.36, 5, 21);
|
||||
@@ -223,17 +223,17 @@ class FactureTestRounding extends CommonClassTest
|
||||
public function testFactureAddLine3()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0
|
||||
$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0;
|
||||
$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0;
|
||||
|
||||
$localobject3=new Facture($db);
|
||||
$localobject3 = new Facture($db);
|
||||
$localobject3->initAsSpecimen('nolines');
|
||||
$facid=$localobject3->create($user);
|
||||
$facid = $localobject3->create($user);
|
||||
$localobject3->addline('Line 1', 6.36, 3, 21);
|
||||
$localobject3->addline('Line 2', 6.36, 3, 21);
|
||||
$localobject3->addline('Line 3', 6.36, 3, 21);
|
||||
@@ -245,11 +245,11 @@ class FactureTestRounding extends CommonClassTest
|
||||
$this->assertEquals(115.45, $localobject3->total_ttc);
|
||||
|
||||
// With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1
|
||||
$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1;
|
||||
$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1;
|
||||
|
||||
$localobject3=new Facture($db);
|
||||
$localobject3 = new Facture($db);
|
||||
$localobject3->initAsSpecimen('nolines');
|
||||
$facid=$localobject3->create($user);
|
||||
$facid = $localobject3->create($user);
|
||||
$localobject3->addline('Line 1', 6.36, 3, 21);
|
||||
$localobject3->addline('Line 2', 6.36, 3, 21);
|
||||
$localobject3->addline('Line 3', 6.36, 3, 21);
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,20 +56,20 @@ class FichinterTest extends CommonClassTest
|
||||
public function testFichinterCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$soc = new Societe($db);
|
||||
$soc->name = "FichinterTest Unittest";
|
||||
$socid = $soc->create($user);
|
||||
$this->assertLessThan($socid, 0, $soc->errorsToString());
|
||||
|
||||
$localobject=new Fichinter($db);
|
||||
$localobject = new Fichinter($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->socid = $socid;
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, $localobject->errorsToString());
|
||||
@@ -89,13 +89,13 @@ class FichinterTest extends CommonClassTest
|
||||
public function testFichinterFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Fichinter($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Fichinter($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, $localobject->errorsToString());
|
||||
@@ -115,12 +115,12 @@ class FichinterTest extends CommonClassTest
|
||||
public function testFichinterValid($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->setValid($user);
|
||||
$result = $localobject->setValid($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertLessThan($result, 0, $localobject->errorsToString());
|
||||
@@ -139,10 +139,10 @@ class FichinterTest extends CommonClassTest
|
||||
public function testFichinterOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
/*$result=$localobject->setstatus(0);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
@@ -168,14 +168,14 @@ class FichinterTest extends CommonClassTest
|
||||
public function testFichinterDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Fichinter($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new Fichinter($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, $localobject->errorsToString());
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,13 +56,13 @@ class FormAdminTest extends CommonClassTest
|
||||
public function testSelectPaperFormat()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new FormAdmin($db);
|
||||
$result=$localobject->select_paper_format('', 'paperformat_id', 'A4', 0, 1);
|
||||
$localobject = new FormAdmin($db);
|
||||
$result = $localobject->select_paper_format('', 'paperformat_id', 'A4', 0, 1);
|
||||
|
||||
$this->assertEquals($result, '<select class="flat" id="paperformat_id" name="paperformat_id"><option value="EUA4">Format A4 - 210x297 mm</option></select>');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,13 +56,13 @@ class FormTest extends CommonClassTest
|
||||
public function testSelectProduitsList()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Form($db);
|
||||
$result=$localobject->select_produits_list('', 'productid', '', 5, 0, '', 1, 2, 1);
|
||||
$localobject = new Form($db);
|
||||
$result = $localobject->select_produits_list('', 'productid', '', 5, 0, '', 1, 2, 1);
|
||||
|
||||
$this->assertEquals(count($result), 5);
|
||||
print __METHOD__." count result=".count($result)."\n";
|
||||
@@ -70,7 +70,7 @@ class FormTest extends CommonClassTest
|
||||
$conf->global->ENTREPOT_EXTRA_STATUS = 1;
|
||||
|
||||
// Exclude stock in warehouseinternal
|
||||
$result=$localobject->select_produits_list('', 'productid', '', 5, 0, '', 1, 2, 1, 0, '1', 0, '', 0, 'warehouseclosed,warehouseopen');
|
||||
$result = $localobject->select_produits_list('', 'productid', '', 5, 0, '', 1, 2, 1, 0, '1', 0, '', 0, 'warehouseclosed,warehouseopen');
|
||||
$this->assertEquals(count($result), 5);
|
||||
print __METHOD__." count result=".count($result)."\n";
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ class Functions2LibTest extends CommonClassTest
|
||||
*/
|
||||
public function testJsUnEscape()
|
||||
{
|
||||
$result=jsUnEscape('%u03BD%u03B5%u03BF');
|
||||
$result = jsUnEscape('%u03BD%u03B5%u03BF');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('νεο', $result);
|
||||
}
|
||||
@@ -173,35 +173,35 @@ class Functions2LibTest extends CommonClassTest
|
||||
public function testIsIP()
|
||||
{
|
||||
// Not valid
|
||||
$ip='a299.299.299.299';
|
||||
$result=is_ip($ip);
|
||||
$ip = 'a299.299.299.299';
|
||||
$result = is_ip($ip);
|
||||
print __METHOD__." for ".$ip." result=".$result."\n";
|
||||
$this->assertEquals(0, $result, $ip);
|
||||
|
||||
// Reserved IP range (not checked by is_ip function)
|
||||
$ip='169.254.0.0';
|
||||
$result=is_ip($ip);
|
||||
$ip = '169.254.0.0';
|
||||
$result = is_ip($ip);
|
||||
print __METHOD__." for ".$ip." result=".$result."\n";
|
||||
//$this->assertEquals(2,$result,$ip); // Assertion disabled because returned value differs between PHP patch version
|
||||
|
||||
$ip='1.2.3.4';
|
||||
$result=is_ip($ip);
|
||||
$ip = '1.2.3.4';
|
||||
$result = is_ip($ip);
|
||||
print __METHOD__." for ".$ip." result=".$result."\n";
|
||||
$this->assertEquals(1, $result, $ip);
|
||||
|
||||
// Private IP ranges
|
||||
$ip='10.0.0.0';
|
||||
$result=is_ip($ip);
|
||||
$ip = '10.0.0.0';
|
||||
$result = is_ip($ip);
|
||||
print __METHOD__." for ".$ip." result=".$result."\n";
|
||||
$this->assertEquals(2, $result, $ip);
|
||||
|
||||
$ip='172.16.0.0';
|
||||
$result=is_ip($ip);
|
||||
$ip = '172.16.0.0';
|
||||
$result = is_ip($ip);
|
||||
print __METHOD__." for ".$ip." result=".$result."\n";
|
||||
$this->assertEquals(2, $result, $ip);
|
||||
|
||||
$ip='192.168.0.0';
|
||||
$result=is_ip($ip);
|
||||
$ip = '192.168.0.0';
|
||||
$result = is_ip($ip);
|
||||
print __METHOD__." for ".$ip." result=".$result."\n";
|
||||
$this->assertEquals(2, $result, $ip);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -37,7 +37,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -57,40 +57,40 @@ class GetUrlLibTest extends CommonClassTest
|
||||
public function testGetRootURLFromURL()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=getRootURLFromURL('http://www.dolimed.com/screenshots/afile');
|
||||
$result = getRootURLFromURL('http://www.dolimed.com/screenshots/afile');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('http://www.dolimed.com', $result, 'Test 1');
|
||||
|
||||
$result=getRootURLFromURL('https://www.dolimed.com/screenshots/afile');
|
||||
$result = getRootURLFromURL('https://www.dolimed.com/screenshots/afile');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('https://www.dolimed.com', $result, 'Test 2');
|
||||
|
||||
$result=getRootURLFromURL('http://www.dolimed.com/screenshots');
|
||||
$result = getRootURLFromURL('http://www.dolimed.com/screenshots');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('http://www.dolimed.com', $result);
|
||||
|
||||
$result=getRootURLFromURL('https://www.dolimed.com/screenshots');
|
||||
$result = getRootURLFromURL('https://www.dolimed.com/screenshots');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('https://www.dolimed.com', $result);
|
||||
|
||||
$result=getRootURLFromURL('http://www.dolimed.com/');
|
||||
$result = getRootURLFromURL('http://www.dolimed.com/');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('http://www.dolimed.com', $result);
|
||||
|
||||
$result=getRootURLFromURL('https://www.dolimed.com/');
|
||||
$result = getRootURLFromURL('https://www.dolimed.com/');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('https://www.dolimed.com', $result);
|
||||
|
||||
$result=getRootURLFromURL('http://www.dolimed.com');
|
||||
$result = getRootURLFromURL('http://www.dolimed.com');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('http://www.dolimed.com', $result);
|
||||
|
||||
$result=getRootURLFromURL('https://www.dolimed.com');
|
||||
$result = getRootURLFromURL('https://www.dolimed.com');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('https://www.dolimed.com', $result);
|
||||
|
||||
@@ -105,64 +105,64 @@ class GetUrlLibTest extends CommonClassTest
|
||||
public function testGetDomainFromURL()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// Tests with param 0
|
||||
|
||||
$result=getDomainFromURL('http://localhost');
|
||||
$result = getDomainFromURL('http://localhost');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('localhost', $result, 'Test localhost 0');
|
||||
|
||||
$result=getDomainFromURL('http://localhost', 1);
|
||||
$result = getDomainFromURL('http://localhost', 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('localhost', $result, 'Test localhost 1');
|
||||
|
||||
$result=getDomainFromURL('https://dolimed.com');
|
||||
$result = getDomainFromURL('https://dolimed.com');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('dolimed', $result, 'Test dolimed.com 0');
|
||||
|
||||
$result=getDomainFromURL('http://www.dolimed.com/screenshots/afile');
|
||||
$result = getDomainFromURL('http://www.dolimed.com/screenshots/afile');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('dolimed', $result, 'Test dolimed.com/... 0');
|
||||
|
||||
$result=getDomainFromURL('http://www.with.dolimed.com/screenshots/afile');
|
||||
$result = getDomainFromURL('http://www.with.dolimed.com/screenshots/afile');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('dolimed', $result, 'Test ...dolimed.com/ 0');
|
||||
|
||||
// Tests with param 1
|
||||
|
||||
$result=getDomainFromURL('https://dolimed.com', 1);
|
||||
$result = getDomainFromURL('https://dolimed.com', 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('dolimed.com', $result, 'Test dolimed.com 1');
|
||||
|
||||
$result=getDomainFromURL('http://www.dolimed.com/screenshots/afile', 1);
|
||||
$result = getDomainFromURL('http://www.dolimed.com/screenshots/afile', 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('dolimed.com', $result, 'Test dolimed.com/... 1');
|
||||
|
||||
$result=getDomainFromURL('http://www.with.dolimed.com/screenshots/afile', 1);
|
||||
$result = getDomainFromURL('http://www.with.dolimed.com/screenshots/afile', 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('dolimed.com', $result, 'Test .../dolimed.com 1');
|
||||
|
||||
// Tests with param 2
|
||||
|
||||
$result=getDomainFromURL('http://www.with.dolimed.com/screenshots/afile', 2);
|
||||
$result = getDomainFromURL('http://www.with.dolimed.com/screenshots/afile', 2);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('with.dolimed.com', $result, 'Test .../dolimed.com 2');
|
||||
|
||||
// For domains with top domain on 2 levels
|
||||
|
||||
$result=getDomainFromURL('https://www.with.dolimed.com.mx', 0);
|
||||
$result = getDomainFromURL('https://www.with.dolimed.com.mx', 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('dolimed', $result, 'Test dolimed.com.mx 0');
|
||||
|
||||
$result=getDomainFromURL('https://www.with.dolimed.com.mx', 1);
|
||||
$result = getDomainFromURL('https://www.with.dolimed.com.mx', 1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('dolimed.com.mx', $result, 'Test dolimed.com.mx 1');
|
||||
|
||||
$result=getDomainFromURL('https://www.with.dolimed.com.mx', 2);
|
||||
$result = getDomainFromURL('https://www.with.dolimed.com.mx', 2);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('with.dolimed.com.mx', $result, 'Test dolimed.com.mx 2');
|
||||
|
||||
@@ -177,16 +177,16 @@ class GetUrlLibTest extends CommonClassTest
|
||||
public function testRemoveHtmlComment()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=removeHtmlComment('abc<!--[if lt IE 8]>aaaa<![endif]-->def');
|
||||
$result = removeHtmlComment('abc<!--[if lt IE 8]>aaaa<![endif]-->def');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('abcdef', $result, 'Test 1');
|
||||
|
||||
$result=removeHtmlComment('abc<!--[if lt IE 8]>aa-->bb<!--aa<![endif]-->def');
|
||||
$result = removeHtmlComment('abc<!--[if lt IE 8]>aa-->bb<!--aa<![endif]-->def');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('abcbbdef', $result, 'Test 1');
|
||||
|
||||
|
||||
@@ -59,14 +59,14 @@ class HolidayTest extends CommonClassTest
|
||||
public function testHolidayCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Holiday($db);
|
||||
$localobject = new Holiday($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -85,13 +85,13 @@ class HolidayTest extends CommonClassTest
|
||||
public function testHolidayFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Holiday($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Holiday($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -111,45 +111,45 @@ class HolidayTest extends CommonClassTest
|
||||
public function testHolidayUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->oldcopy = clone $localobject;
|
||||
|
||||
$localobject->note_private='New private note after update';
|
||||
$localobject->note_public='New public note after update';
|
||||
$localobject->lastname='New name';
|
||||
$localobject->firstname='New firstname';
|
||||
$localobject->address='New address';
|
||||
$localobject->zip='New zip';
|
||||
$localobject->town='New town';
|
||||
$localobject->country_id=2;
|
||||
$localobject->note_private = 'New private note after update';
|
||||
$localobject->note_public = 'New public note after update';
|
||||
$localobject->lastname = 'New name';
|
||||
$localobject->firstname = 'New firstname';
|
||||
$localobject->address = 'New address';
|
||||
$localobject->zip = 'New zip';
|
||||
$localobject->town = 'New town';
|
||||
$localobject->country_id = 2;
|
||||
//$localobject->status=0;
|
||||
$localobject->phone_pro='New tel pro';
|
||||
$localobject->phone_perso='New tel perso';
|
||||
$localobject->phone_mobile='New tel mobile';
|
||||
$localobject->fax='New fax';
|
||||
$localobject->email='newemail@newemail.com';
|
||||
$localobject->jabberid='New im id';
|
||||
$localobject->default_lang='es_ES';
|
||||
$localobject->phone_pro = 'New tel pro';
|
||||
$localobject->phone_perso = 'New tel perso';
|
||||
$localobject->phone_mobile = 'New tel mobile';
|
||||
$localobject->fax = 'New fax';
|
||||
$localobject->email = 'newemail@newemail.com';
|
||||
$localobject->jabberid = 'New im id';
|
||||
$localobject->default_lang = 'es_ES';
|
||||
|
||||
$result=$localobject->update($localobject->id, $user);
|
||||
$result = $localobject->update($localobject->id, $user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, 'Holiday::update error');
|
||||
|
||||
$result=$localobject->update_note($localobject->note_private, '_private');
|
||||
$result = $localobject->update_note($localobject->note_private, '_private');
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, 'Holiday::update_note (private) error');
|
||||
|
||||
$result=$localobject->update_note($localobject->note_public, '_public');
|
||||
$result = $localobject->update_note($localobject->note_public, '_public');
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, 'Holiday::update_note (public) error');
|
||||
|
||||
|
||||
$newobject=new Holiday($db);
|
||||
$result=$newobject->fetch($localobject->id);
|
||||
$newobject = new Holiday($db);
|
||||
$result = $newobject->fetch($localobject->id);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, 'Holiday::fetch error');
|
||||
|
||||
@@ -173,10 +173,10 @@ class HolidayTest extends CommonClassTest
|
||||
public function testHolidayOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result = $localobject->fetchUsers(true, true, '');
|
||||
$this->assertNotEquals($result, -1);
|
||||
@@ -205,15 +205,15 @@ class HolidayTest extends CommonClassTest
|
||||
public function testHolidayDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Holiday($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Holiday($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$result=$localobject->delete($user);
|
||||
$result = $localobject->delete($user);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -228,54 +228,54 @@ class HolidayTest extends CommonClassTest
|
||||
public function testVerifDateHolidayCP()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// Create a leave request the 1st morning only
|
||||
$localobjecta=new Holiday($db);
|
||||
$localobjecta = new Holiday($db);
|
||||
$localobjecta->initAsSpecimen();
|
||||
$localobjecta->date_debut = dol_mktime(0, 0, 0, 1, 1, 2020);
|
||||
$localobjecta->date_fin = dol_mktime(0, 0, 0, 1, 1, 2020);
|
||||
$localobjecta->halfday = 1;
|
||||
$result=$localobjecta->create($user);
|
||||
$result = $localobjecta->create($user);
|
||||
|
||||
// Create a leave request the 2 afternoon only
|
||||
$localobjectb=new Holiday($db);
|
||||
$localobjectb = new Holiday($db);
|
||||
$localobjectb->initAsSpecimen();
|
||||
$localobjectb->date_debut = dol_mktime(0, 0, 0, 1, 2, 2020);
|
||||
$localobjectb->date_fin = dol_mktime(0, 0, 0, 1, 2, 2020);
|
||||
$localobjectb->halfday = -1;
|
||||
$result=$localobjectb->create($user);
|
||||
$result = $localobjectb->create($user);
|
||||
|
||||
$date_debut = dol_mktime(0, 0, 0, 1, 1, 2020);
|
||||
$date_fin = dol_mktime(0, 0, 0, 1, 2, 2020);
|
||||
|
||||
$localobjectc=new Holiday($db);
|
||||
$localobjectc = new Holiday($db);
|
||||
|
||||
$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 0);
|
||||
$result = $localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 0);
|
||||
$this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.');
|
||||
$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 0);
|
||||
$result = $localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 0);
|
||||
$this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.');
|
||||
$result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 0);
|
||||
$result = $localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 0);
|
||||
$this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.');
|
||||
|
||||
$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 1);
|
||||
$result = $localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 1);
|
||||
$this->assertFalse($result, 'result should be false, there is overlapping, morning of first day is not available.');
|
||||
$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 1);
|
||||
$result = $localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 1);
|
||||
$this->assertFalse($result, 'result should be false, there is overlapping, morning of first day is not available.');
|
||||
$result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 1);
|
||||
$result = $localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 1);
|
||||
$this->assertTrue($result, 'result should be true, there is no overlapping');
|
||||
|
||||
$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, -1);
|
||||
$result = $localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, -1);
|
||||
$this->assertTrue($result, 'result should be true, there is no overlapping');
|
||||
$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, -1);
|
||||
$result = $localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, -1);
|
||||
$this->assertFalse($result, 'result should be false, there is overlapping, afternoon of second day is not available');
|
||||
$result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, -1);
|
||||
$result = $localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, -1);
|
||||
$this->assertFalse($result, 'result should be false, there is overlapping, afternoon of second day is not available');
|
||||
|
||||
$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 2); // start afternoon and end morning
|
||||
$result = $localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 2); // start afternoon and end morning
|
||||
$this->assertTrue($result, 'result should be true, there is no overlapping');
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ class HolidayTest extends CommonClassTest
|
||||
{
|
||||
global $db;
|
||||
|
||||
$localobjecta=new Holiday($db);
|
||||
$localobjecta = new Holiday($db);
|
||||
|
||||
$localobjecta->updateConfCP('lastUpdate', '20100101120000');
|
||||
$result = $localobjecta->updateBalance();
|
||||
|
||||
@@ -38,7 +38,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -57,14 +57,14 @@ class ImagesLibTest extends CommonClassTest
|
||||
*/
|
||||
public function testgetImageSize()
|
||||
{
|
||||
$file=dirname(__FILE__).'/img250x50.jpg';
|
||||
$tmp=dol_getImageSize($file);
|
||||
$file = dirname(__FILE__).'/img250x50.jpg';
|
||||
$tmp = dol_getImageSize($file);
|
||||
print __METHOD__." result=".$tmp['width'].'/'.$tmp['height']."\n";
|
||||
$this->assertEquals($tmp['width'], 250);
|
||||
$this->assertEquals($tmp['height'], 50);
|
||||
|
||||
$file=dirname(__FILE__).'/img250x20.png';
|
||||
$tmp=dol_getImageSize($file);
|
||||
$file = dirname(__FILE__).'/img250x20.png';
|
||||
$tmp = dol_getImageSize($file);
|
||||
print __METHOD__." result=".$tmp['width'].'/'.$tmp['height']."\n";
|
||||
$this->assertEquals($tmp['width'], 250);
|
||||
$this->assertEquals($tmp['height'], 20);
|
||||
@@ -87,8 +87,8 @@ class ImagesLibTest extends CommonClassTest
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$file=dirname(__FILE__).'/img250x20.png';
|
||||
$filetarget=$conf->admin->dir_temp.'/img250x20.jpg';
|
||||
$file = dirname(__FILE__).'/img250x20.png';
|
||||
$filetarget = $conf->admin->dir_temp.'/img250x20.jpg';
|
||||
dol_delete_file($filetarget);
|
||||
$result = dol_imageResizeOrCrop($file, 0, 0, 0, 0, 0, $filetarget);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
|
||||
@@ -78,7 +78,7 @@ class ImportTest extends CommonClassTest
|
||||
*/
|
||||
public function testImportSample1()
|
||||
{
|
||||
$file=dirname(__FILE__).'/Example_import_company_1.csv';
|
||||
$file = dirname(__FILE__).'/Example_import_company_1.csv';
|
||||
|
||||
// TODO
|
||||
// Run import on file and check the record with field "auto" are filled
|
||||
|
||||
@@ -37,7 +37,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -57,14 +57,14 @@ class InventoryTest extends CommonClassTest
|
||||
public function testInventoryCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Inventory($db);
|
||||
$localobject = new Inventory($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
return $result;
|
||||
@@ -82,13 +82,13 @@ class InventoryTest extends CommonClassTest
|
||||
public function testInventoryFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Inventory($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Inventory($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
@@ -107,14 +107,14 @@ class InventoryTest extends CommonClassTest
|
||||
public function testInventoryUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->status = 9;
|
||||
$localobject->title = 'test';
|
||||
$result=$localobject->update($user, $user);
|
||||
$result = $localobject->update($user, $user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
return $localobject;
|
||||
@@ -133,12 +133,12 @@ class InventoryTest extends CommonClassTest
|
||||
public function testInventoryValidate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->validate($user);
|
||||
$result = $localobject->validate($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -158,12 +158,12 @@ class InventoryTest extends CommonClassTest
|
||||
public function testInventorySetDraft($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->setDraft($user);
|
||||
$result = $localobject->setDraft($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -183,12 +183,12 @@ class InventoryTest extends CommonClassTest
|
||||
public function testInventorySetRecorded($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->setRecorded($user);
|
||||
$result = $localobject->setRecorded($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -208,12 +208,12 @@ class InventoryTest extends CommonClassTest
|
||||
public function testInventorySetCanceled($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->setCanceled($user);
|
||||
$result = $localobject->setCanceled($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -232,10 +232,10 @@ class InventoryTest extends CommonClassTest
|
||||
public function testInventoryOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->info($localobject->id);
|
||||
print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n";
|
||||
@@ -254,14 +254,14 @@ class InventoryTest extends CommonClassTest
|
||||
public function testInventoryDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Inventory($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new Inventory($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -279,23 +279,23 @@ class InventoryTest extends CommonClassTest
|
||||
*/
|
||||
public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id'))
|
||||
{
|
||||
$retAr=array();
|
||||
$retAr = array();
|
||||
|
||||
if (get_class($oA) !== get_class($oB)) {
|
||||
$retAr[]="Supplied objects are not of same class.";
|
||||
$retAr[] = "Supplied objects are not of same class.";
|
||||
} else {
|
||||
$oVarsA=get_object_vars($oA);
|
||||
$oVarsB=get_object_vars($oB);
|
||||
$aKeys=array_keys($oVarsA);
|
||||
$oVarsA = get_object_vars($oA);
|
||||
$oVarsB = get_object_vars($oB);
|
||||
$aKeys = array_keys($oVarsA);
|
||||
foreach ($aKeys as $sKey) {
|
||||
if (in_array($sKey, $fieldstoignorearray)) {
|
||||
continue;
|
||||
}
|
||||
if (! $ignoretype && ($oVarsA[$sKey] !== $oVarsB[$sKey])) {
|
||||
$retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
|
||||
$retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
|
||||
}
|
||||
if ($ignoretype && ($oVarsA[$sKey] != $oVarsB[$sKey])) {
|
||||
$retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
|
||||
$retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,55 +80,55 @@ class JsonLibTest extends CommonClassTest
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
$this->savconf = $conf;
|
||||
$this->savuser = $user;
|
||||
$this->savlangs = $langs;
|
||||
$this->savdb = $db;
|
||||
|
||||
// Try to decode a string encoded with serialize
|
||||
$encoded = 'a:1:{s:7:"options";a:3:{s:3:"app";s:11:"Application";s:6:"system";s:6:"System";s:6:"option";s:6:"Option";}}';
|
||||
$decoded=json_decode($encoded, true);
|
||||
$decoded = json_decode($encoded, true);
|
||||
$this->assertEquals(null, $decoded, 'test to json_decode() a string that was encoded with serialize()');
|
||||
|
||||
$encoded = 'rubishstring!aa{bcd';
|
||||
$decoded=json_decode($encoded, true);
|
||||
$decoded = json_decode($encoded, true);
|
||||
$this->assertEquals(null, $decoded, 'test to json_decode() a string that was encoded with serialize()');
|
||||
|
||||
// Do a test with an array starting with 0
|
||||
$arraytotest=array(0=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "'));
|
||||
$arrayencodedexpected='[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]';
|
||||
$arraytotest = array(0 => array('key' => 1,'value' => 'PRODREF','label' => 'Product ref with é and special chars \\ \' "'));
|
||||
$arrayencodedexpected = '[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]';
|
||||
|
||||
$encoded=json_encode($arraytotest);
|
||||
$encoded = json_encode($arraytotest);
|
||||
$this->assertEquals($arrayencodedexpected, $encoded);
|
||||
$decoded=json_decode($encoded, true);
|
||||
$decoded = json_decode($encoded, true);
|
||||
$this->assertEquals($arraytotest, $decoded, 'test for json_xxx');
|
||||
|
||||
$encoded=dol_json_encode($arraytotest);
|
||||
$encoded = dol_json_encode($arraytotest);
|
||||
$this->assertEquals($arrayencodedexpected, $encoded);
|
||||
$decoded=dol_json_decode($encoded, true);
|
||||
$decoded = dol_json_decode($encoded, true);
|
||||
$this->assertEquals($arraytotest, $decoded, 'test for dol_json_xxx');
|
||||
|
||||
// Same test but array start with 2 instead of 0
|
||||
$arraytotest=array(2=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "'));
|
||||
$arrayencodedexpected='{"2":{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}}';
|
||||
$arraytotest = array(2 => array('key' => 1,'value' => 'PRODREF','label' => 'Product ref with é and special chars \\ \' "'));
|
||||
$arrayencodedexpected = '{"2":{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}}';
|
||||
|
||||
$encoded=json_encode($arraytotest);
|
||||
$encoded = json_encode($arraytotest);
|
||||
$this->assertEquals($arrayencodedexpected, $encoded);
|
||||
$decoded=json_decode($encoded, true);
|
||||
$decoded = json_decode($encoded, true);
|
||||
$this->assertEquals($arraytotest, $decoded, 'test for json_xxx');
|
||||
|
||||
$encoded=dol_json_encode($arraytotest);
|
||||
$encoded = dol_json_encode($arraytotest);
|
||||
$this->assertEquals($arrayencodedexpected, $encoded);
|
||||
$decoded=dol_json_decode($encoded, true);
|
||||
$decoded = dol_json_decode($encoded, true);
|
||||
$this->assertEquals($arraytotest, $decoded, 'test for dol_json_xxx');
|
||||
|
||||
// Test with object
|
||||
$now=gmmktime(12, 0, 0, 1, 1, 1970);
|
||||
$objecttotest=new stdClass();
|
||||
$objecttotest->property1='abc';
|
||||
$objecttotest->property2=1234;
|
||||
$objecttotest->property3=$now;
|
||||
$encoded=dol_json_encode($objecttotest);
|
||||
$now = gmmktime(12, 0, 0, 1, 1, 1970);
|
||||
$objecttotest = new stdClass();
|
||||
$objecttotest->property1 = 'abc';
|
||||
$objecttotest->property2 = 1234;
|
||||
$objecttotest->property3 = $now;
|
||||
$encoded = dol_json_encode($objecttotest);
|
||||
$this->assertEquals('{"property1":"abc","property2":1234,"property3":43200}', $encoded);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,13 +104,13 @@ class KnowledgeRecordTest extends CommonClassTest
|
||||
public function testKnowledgeRecordFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new KnowledgeRecord($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new KnowledgeRecord($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
@@ -133,7 +133,7 @@ class KnowledgeRecordTest extends CommonClassTest
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->note_private='New note private after update';
|
||||
$localobject->note_private = 'New note private after update';
|
||||
$result = $localobject->update($user);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -68,7 +68,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -88,10 +88,10 @@ class LangTest extends CommonClassTest
|
||||
public function testLang()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
|
||||
|
||||
@@ -102,32 +102,32 @@ class LangTest extends CommonClassTest
|
||||
}
|
||||
|
||||
print 'Check language file for lang code='.$code."\n";
|
||||
$tmplangs=new Translate('', $conf);
|
||||
$langcode=$code;
|
||||
$tmplangs = new Translate('', $conf);
|
||||
$langcode = $code;
|
||||
$tmplangs->setDefaultLang($langcode);
|
||||
$tmplangs->load("main");
|
||||
|
||||
$result=$tmplangs->transnoentitiesnoconv("FONTFORPDF");
|
||||
$result = $tmplangs->transnoentitiesnoconv("FONTFORPDF");
|
||||
print __METHOD__." FONTFORPDF=".$result."\n";
|
||||
$this->assertTrue(in_array($result, array('msungstdlight', 'stsongstdlight', 'helvetica', 'DejaVuSans', 'cid0jp', 'cid0kr', 'freemono', 'freeserif')), 'Error bad value '.$result.' for FONTFORPDF in main.lang file '.$code);
|
||||
|
||||
$result=$tmplangs->transnoentitiesnoconv("DIRECTION");
|
||||
$result = $tmplangs->transnoentitiesnoconv("DIRECTION");
|
||||
print __METHOD__." DIRECTION=".$result."\n";
|
||||
$this->assertTrue(in_array($result, array('rtl', 'ltr')), 'Error bad value for DIRECTION in main.lang file '.$code);
|
||||
|
||||
$result=$tmplangs->transnoentitiesnoconv("SeparatorDecimal");
|
||||
$result = $tmplangs->transnoentitiesnoconv("SeparatorDecimal");
|
||||
print __METHOD__." SeparatorDecimal=".$result."\n";
|
||||
$this->assertTrue(in_array($result, array('.',',','/',' ','','None')), 'Error on decimal separator for lang code '.$code); // Note that ، that is coma for RTL languages is not supported
|
||||
|
||||
$result=$tmplangs->transnoentitiesnoconv("SeparatorThousand");
|
||||
$result = $tmplangs->transnoentitiesnoconv("SeparatorThousand");
|
||||
print __METHOD__." SeparatorThousand=".$result."\n";
|
||||
$this->assertTrue(in_array($result, array('.',',','/',' ','','\'','None','Space')), 'Error on thousand separator for lang code '.$code); // Note that ، that is coma for RTL languages is not supported
|
||||
|
||||
// Test java string contains only d,M,y,/,-,. and not m,...
|
||||
$result=$tmplangs->transnoentitiesnoconv("FormatDateShortJava");
|
||||
$result = $tmplangs->transnoentitiesnoconv("FormatDateShortJava");
|
||||
print __METHOD__." FormatDateShortJava=".$result."\n";
|
||||
$this->assertRegExp('/^[dMy\/\-\.]+$/', $result, 'FormatDateShortJava KO for lang code '.$code);
|
||||
$result=$tmplangs->trans("FormatDateShortJavaInput");
|
||||
$result = $tmplangs->trans("FormatDateShortJavaInput");
|
||||
print __METHOD__." FormatDateShortJavaInput=".$result."\n";
|
||||
$this->assertRegExp('/^[dMy\/\-\.]+$/', $result, 'FormatDateShortJavaInput KO for lang code '.$code);
|
||||
|
||||
@@ -141,21 +141,21 @@ class LangTest extends CommonClassTest
|
||||
}
|
||||
|
||||
//print 'Check lang file '.$file."\n";
|
||||
$filecontent=file_get_contents(DOL_DOCUMENT_ROOT.'/langs/'.$code.'/'.$file);
|
||||
$filecontent = file_get_contents(DOL_DOCUMENT_ROOT.'/langs/'.$code.'/'.$file);
|
||||
|
||||
$result=preg_match('/=--$/m', $filecontent); // A special % char we don't want. We want the common one.
|
||||
$result = preg_match('/=--$/m', $filecontent); // A special % char we don't want. We want the common one.
|
||||
//print __METHOD__." Result for checking we don't have bad percent char = ".$result."\n";
|
||||
$this->assertTrue($result == 0, 'Found a translation KEY=-- into file '.$code.'/'.$file.'. We probably want Key=- instead.');
|
||||
|
||||
$result=strpos($filecontent, '%'); // A special % char we don't want. We want the common one.
|
||||
$result = strpos($filecontent, '%'); // A special % char we don't want. We want the common one.
|
||||
//print __METHOD__." Result for checking we don't have bad percent char = ".$result."\n";
|
||||
$this->assertTrue($result === false, 'Found a bad percent char % instead of % into file '.$code.'/'.$file);
|
||||
|
||||
$result=preg_match('/%n/m', $filecontent); // A sequence of char we don't want
|
||||
$result = preg_match('/%n/m', $filecontent); // A sequence of char we don't want
|
||||
//print __METHOD__." Result for checking we don't have bad percent char = ".$result."\n";
|
||||
$this->assertTrue($result == 0, 'Found a sequence %n into the translation file '.$code.'/'.$file.'. We probably want %s');
|
||||
|
||||
$result=preg_match('/<<<<</m', $filecontent); // A sequence of char we don't want
|
||||
$result = preg_match('/<<<<</m', $filecontent); // A sequence of char we don't want
|
||||
//print __METHOD__." Result for checking we don't have bad percent char = ".$result."\n";
|
||||
$this->assertTrue($result == 0, 'Found a sequence <<<<< into the translation file '.$code.'/'.$file.'. Probably a bad merge of code were done.');
|
||||
}
|
||||
@@ -172,13 +172,13 @@ class LangTest extends CommonClassTest
|
||||
public function testTrans()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$tmplangs=new Translate('', $conf);
|
||||
$langcode='en_US';
|
||||
$tmplangs = new Translate('', $conf);
|
||||
$langcode = 'en_US';
|
||||
$tmplangs->setDefaultLang($langcode);
|
||||
$tmplangs->load("main");
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -88,10 +88,10 @@ class LesscTest extends CommonClassTest
|
||||
public function testLessc()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/lessc.class.php';
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,14 +56,14 @@ class LoanTest extends CommonClassTest
|
||||
public function testLoanCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Loan($db);
|
||||
$localobject = new Loan($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -82,13 +82,13 @@ class LoanTest extends CommonClassTest
|
||||
public function testLoanFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Loan($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Loan($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
@@ -107,12 +107,12 @@ class LoanTest extends CommonClassTest
|
||||
public function testLoanOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->setPaid($user);
|
||||
$result = $localobject->setPaid($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -131,14 +131,14 @@ class LoanTest extends CommonClassTest
|
||||
public function testLoanDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Loan($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new Loan($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,12 +56,12 @@ class MarginsLibTest extends CommonClassTest
|
||||
public function testGetMarginInfos()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=getMarginInfos(10, 0, 19.6, 0, 0, 0, 8);
|
||||
$result = getMarginInfos(10, 0, 19.6, 0, 0, 0, 8);
|
||||
//var_dump($result);
|
||||
print __METHOD__." result[0]=".$result[0]."\n";
|
||||
$this->assertEquals(8, $result[0]);
|
||||
@@ -70,13 +70,13 @@ class MarginsLibTest extends CommonClassTest
|
||||
print __METHOD__." result[2]=".$result[2]."\n";
|
||||
$this->assertEquals(20, $result[2]);
|
||||
|
||||
$result=getMarginInfos(10, 10, 19.6, 0, 0, 0, 8);
|
||||
$result = getMarginInfos(10, 10, 19.6, 0, 0, 0, 8);
|
||||
print __METHOD__." result[0]=".$result[0]."\n";
|
||||
$this->assertEquals(8, $result[0]);
|
||||
print __METHOD__." result[1]=".$result[1]."\n";
|
||||
$this->assertEquals(12.5, $result[1]);
|
||||
print __METHOD__." result[2]=".$result[2]."\n";
|
||||
$this->assertEquals(1/9*100, $result[2]);
|
||||
$this->assertEquals(1 / 9 * 100, $result[2]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -55,12 +55,12 @@ class ModulesTest extends CommonClassTest
|
||||
public function testModulesInit()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$modulelist=array('Accounting','Adherent','Agenda','Api','Asset','Banque','Barcode','BlockedLog','Bom','Bookmark',
|
||||
$modulelist = array('Accounting','Adherent','Agenda','Api','Asset','Banque','Barcode','BlockedLog','Bom','Bookmark',
|
||||
'Categorie','ClickToDial','Collab','Commande','Comptabilite','Contrat','Cron','DataPolicy','Dav','DebugBar','Deplacement','DocumentGeneration','Don','DynamicPrices',
|
||||
'ECM','EmailCollector','EventOrganization','Expedition','ExpenseReport','Export','ExternalRss','ExternalSite',
|
||||
'Facture','Fckeditor','Ficheinter','Fournisseur','FTP','GeoIPMaxmind','Gravatar','Holiday','HRM','Import','Incoterm','Intracommreport',
|
||||
@@ -72,17 +72,17 @@ class ModulesTest extends CommonClassTest
|
||||
'TakePos','Tax','Ticket','User','Variants','WebServices','WebServicesClient','Website','Workflow','Workstation','Zapier');
|
||||
foreach ($modulelist as $modlabel) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$modlabel.'.class.php';
|
||||
$class='mod'.$modlabel;
|
||||
$mod=new $class($db);
|
||||
$class = 'mod'.$modlabel;
|
||||
$mod = new $class($db);
|
||||
|
||||
$result=$mod->remove();
|
||||
$result=$mod->init();
|
||||
$result = $mod->remove();
|
||||
$result = $mod->init();
|
||||
|
||||
$this->assertLessThan($result, 0, $modlabel." ".$mod->error);
|
||||
print __METHOD__." test remove/init for module ".$modlabel.", result=".$result."\n";
|
||||
|
||||
if (in_array($modlabel, array('Ldap', 'MailmanSpip'))) {
|
||||
$result=$mod->remove();
|
||||
$result = $mod->remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -58,10 +58,10 @@ class MouvementStockTest extends CommonClassTest
|
||||
protected function setUp(): void
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
if (!isModEnabled('productbatch')) {
|
||||
print "\n".__METHOD__." module Lot/Serial must be enabled.\n";
|
||||
@@ -80,97 +80,97 @@ class MouvementStockTest extends CommonClassTest
|
||||
public function testMouvementCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// We create a product for tests
|
||||
$product0=new Product($db);
|
||||
$product0 = new Product($db);
|
||||
$product0->initAsSpecimen();
|
||||
$product0->ref.=' phpunit 0';
|
||||
$product0->label.=' phpunit 0';
|
||||
$product0->ref .= ' phpunit 0';
|
||||
$product0->label .= ' phpunit 0';
|
||||
$product0->status_batch = 1;
|
||||
$product0id=$product0->create($user);
|
||||
$product0id = $product0->create($user);
|
||||
|
||||
print __METHOD__." product0id=".$product0id."\n";
|
||||
$this->assertGreaterThan(0, $product0id, 'Failed to create product');
|
||||
|
||||
$product1=new Product($db);
|
||||
$product1 = new Product($db);
|
||||
$product1->initAsSpecimen();
|
||||
$product1->ref.=' phpunit 1';
|
||||
$product1->label.=' phpunit 1';
|
||||
$product1id=$product1->create($user);
|
||||
$product1->ref .= ' phpunit 1';
|
||||
$product1->label .= ' phpunit 1';
|
||||
$product1id = $product1->create($user);
|
||||
|
||||
$product2=new Product($db);
|
||||
$product2 = new Product($db);
|
||||
$product2->initAsSpecimen();
|
||||
$product2->ref.=' phpunit 2';
|
||||
$product2->label.=' phpunit 2';
|
||||
$product2id=$product2->create($user);
|
||||
$product2->ref .= ' phpunit 2';
|
||||
$product2->label .= ' phpunit 2';
|
||||
$product2id = $product2->create($user);
|
||||
|
||||
// We create a product for tests
|
||||
$warehouse0=new Entrepot($db);
|
||||
$warehouse0 = new Entrepot($db);
|
||||
$warehouse0->initAsSpecimen();
|
||||
$warehouse0->label.=' phpunit 0';
|
||||
$warehouse0->description.=' phpunit 0';
|
||||
$warehouse0->label .= ' phpunit 0';
|
||||
$warehouse0->description .= ' phpunit 0';
|
||||
$warehouse0->statut = 0;
|
||||
$warehouse0id=$warehouse0->create($user);
|
||||
$warehouse0id = $warehouse0->create($user);
|
||||
|
||||
$warehouse1=new Entrepot($db);
|
||||
$warehouse1 = new Entrepot($db);
|
||||
$warehouse1->initAsSpecimen();
|
||||
$warehouse1->label.=' phpunit 1';
|
||||
$warehouse1->description.=' phpunit 1';
|
||||
$warehouse1id=$warehouse1->create($user);
|
||||
$warehouse1->label .= ' phpunit 1';
|
||||
$warehouse1->description .= ' phpunit 1';
|
||||
$warehouse1id = $warehouse1->create($user);
|
||||
|
||||
$warehouse2=new Entrepot($db);
|
||||
$warehouse2 = new Entrepot($db);
|
||||
$warehouse2->initAsSpecimen();
|
||||
$warehouse2->label.=' phpunit 2';
|
||||
$warehouse2->description.=' phpunit 2';
|
||||
$warehouse2id=$warehouse2->create($user);
|
||||
$warehouse2->label .= ' phpunit 2';
|
||||
$warehouse2->description .= ' phpunit 2';
|
||||
$warehouse2id = $warehouse2->create($user);
|
||||
|
||||
$localobject=new MouvementStock($db);
|
||||
$localobject = new MouvementStock($db);
|
||||
|
||||
$datetest1 = dol_mktime(0, 0, 0, 1, 1, 2000);
|
||||
$datetest2 = dol_mktime(0, 0, 0, 1, 2, 2000);
|
||||
|
||||
// Create an input movement movement (type = 3) with value for eatby date and a lot $datetest1
|
||||
$result=$localobject->reception($user, $product0id, $warehouse0id, 5, 999, 'Movement for unit test with batch', $datetest1, $datetest1, 'anotyetuselotnumberA', '', 0, 'Inventory Code Test with batch');
|
||||
$result = $localobject->reception($user, $product0id, $warehouse0id, 5, 999, 'Movement for unit test with batch', $datetest1, $datetest1, 'anotyetuselotnumberA', '', 0, 'Inventory Code Test with batch');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result, 'Failed to create a movement with a lot number '.$datetest1.' for product id='.$product0id.' with status_batch=1');
|
||||
|
||||
$result=$localobject->reception($user, $product0id, $warehouse0id, 5, 999, 'Movement for unit test with batch', $datetest1, $datetest1, 'anotyetuselotnumberB', '', 0, 'Inventory Code Test with batch');
|
||||
$result = $localobject->reception($user, $product0id, $warehouse0id, 5, 999, 'Movement for unit test with batch', $datetest1, $datetest1, 'anotyetuselotnumberB', '', 0, 'Inventory Code Test with batch');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result, 'Test to check we can create a movement a eatby dare different when lot number is different');
|
||||
|
||||
// Create same input movement movement (type = 3) with same lot but a different value of eatby date
|
||||
$result=$localobject->reception($user, $product0id, $warehouse0id, 5, 999, 'Movement for unit test with batch', $datetest2, $datetest1, 'anotyetuselotnumberA', '', 0, 'Inventory Code Test with batch');
|
||||
$result = $localobject->reception($user, $product0id, $warehouse0id, 5, 999, 'Movement for unit test with batch', $datetest2, $datetest1, 'anotyetuselotnumberA', '', 0, 'Inventory Code Test with batch');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(-3, $result, 'Test to check we can t create a movement for a lot with a different eatby date');
|
||||
|
||||
// Do a list of movement into warehouse 1
|
||||
|
||||
// Create an input movement (type = 3) of price 9.9 -> should update PMP to 9.9
|
||||
$result=$localobject->reception($user, $product1id, $warehouse1id, 10, 9.9, 'Movement for unit test 1', '', '', '', '', 0, 'Inventory Code Test');
|
||||
$result = $localobject->reception($user, $product1id, $warehouse1id, 10, 9.9, 'Movement for unit test 1', '', '', '', '', 0, 'Inventory Code Test');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result, 'Return code of 0 was expected for the reception test 1');
|
||||
|
||||
// Create an input movement (type = 3) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8
|
||||
$result=$localobject->reception($user, $product1id, $warehouse1id, 10, 9.7, 'Movement for unit test 2', '', '', '', '', 0, 'Inventory Code Test');
|
||||
$result = $localobject->reception($user, $product1id, $warehouse1id, 10, 9.7, 'Movement for unit test 2', '', '', '', '', 0, 'Inventory Code Test');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
|
||||
// Create an output movement (type = 2) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8
|
||||
$result=$localobject->livraison($user, $product1id, $warehouse1id, 5, 999, 'Movement for unit test 3', '', '', '', '', 0, 'Inventory Code Test');
|
||||
$result = $localobject->livraison($user, $product1id, $warehouse1id, 5, 999, 'Movement for unit test 3', '', '', '', '', 0, 'Inventory Code Test');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
|
||||
// Create an output movement (type = 1) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8
|
||||
$result=$localobject->_create($user, $product1id, $warehouse1id, 1, 0, 0, 'Input from transfer', 'Transfert X');
|
||||
$result = $localobject->_create($user, $product1id, $warehouse1id, 1, 0, 0, 'Input from transfer', 'Transfert X');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
|
||||
// Create an output movement (type = 1) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8
|
||||
$result=$localobject->_create($user, $product1id, $warehouse1id, -2, 1, 0, 'Output from transfer', 'Transfert Y');
|
||||
$result = $localobject->_create($user, $product1id, $warehouse1id, -2, 1, 0, 'Output from transfer', 'Transfert Y');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
|
||||
@@ -178,27 +178,27 @@ class MouvementStockTest extends CommonClassTest
|
||||
// Do same but into warehouse 2
|
||||
|
||||
// Create an input movement (type = 3) of price 9.9 -> should update PMP to 9.9
|
||||
$result=$localobject->reception($user, $product1id, $warehouse2id, 10, 9.9, 'Movement for unit test 1 wh 2', '', '', '', '', 0, 'Inventory Code Test 2');
|
||||
$result = $localobject->reception($user, $product1id, $warehouse2id, 10, 9.9, 'Movement for unit test 1 wh 2', '', '', '', '', 0, 'Inventory Code Test 2');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
|
||||
// Create an input movement (type = 3) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8
|
||||
$result=$localobject->reception($user, $product1id, $warehouse2id, 10, 9.7, 'Movement for unit test 2 wh 2', '', '', '', '', 0, 'Inventory Code Test 2');
|
||||
$result = $localobject->reception($user, $product1id, $warehouse2id, 10, 9.7, 'Movement for unit test 2 wh 2', '', '', '', '', 0, 'Inventory Code Test 2');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
|
||||
// Create an output movement (type = 2) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8
|
||||
$result=$localobject->livraison($user, $product1id, $warehouse2id, 5, 999, 'Movement for unit test 3 wh 2', '', '', '', '', 0, 'Inventory Code Test 2');
|
||||
$result = $localobject->livraison($user, $product1id, $warehouse2id, 5, 999, 'Movement for unit test 3 wh 2', '', '', '', '', 0, 'Inventory Code Test 2');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
|
||||
// Create an output movement (type = 1) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8
|
||||
$result=$localobject->_create($user, $product1id, $warehouse2id, 1, 0, 0, 'Input from transfer wh 2', 'Transfert X 2');
|
||||
$result = $localobject->_create($user, $product1id, $warehouse2id, 1, 0, 0, 'Input from transfer wh 2', 'Transfert X 2');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result, 'Test create A');
|
||||
|
||||
// Create an output movement (type = 1) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8
|
||||
$result=$localobject->_create($user, $product1id, $warehouse2id, -2, 1, 0, 'Output from transfer wh 2', 'Transfert Y 2');
|
||||
$result = $localobject->_create($user, $product1id, $warehouse2id, -2, 1, 0, 'Output from transfer wh 2', 'Transfert Y 2');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result, 'Test create B');
|
||||
|
||||
@@ -217,10 +217,10 @@ class MouvementStockTest extends CommonClassTest
|
||||
public function testMouvementCheck($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$productid = $localobject->product_id;
|
||||
$warehouseid = $localobject->entrepot_id;
|
||||
|
||||
@@ -35,7 +35,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -55,524 +55,524 @@ class NumberingModulesTest extends CommonClassTest
|
||||
public function testFactureMercure()
|
||||
{
|
||||
global $conf,$user,$langs,$db,$mysoc;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
require_once dirname(__FILE__).'/../../htdocs/compta/facture/class/facture.class.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/facture/mod_facture_mercure.php';
|
||||
|
||||
// First we try with a simple mask, with no reset
|
||||
// and we test counter is still increase second year.
|
||||
$conf->global->FACTURE_ADDON='mercure';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_DEPOSIT='{yyyy}-{0000}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_REPLACEMENT='{yyyy}-{0000}';
|
||||
$conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED=0;
|
||||
$conf->global->FACTURE_ADDON = 'mercure';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}-{0000}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}-{0000}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_DEPOSIT = '{yyyy}-{0000}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_REPLACEMENT = '{yyyy}-{0000}';
|
||||
$conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED = 0;
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1915); // we use year 1915 to be sure to not have existing invoice for this year (useful only if numbering is {0000@1}
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1915); // we use year 1915 to be sure to not have existing invoice for this year (useful only if numbering is {0000@1}
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1915-0001', $result, 'Test for {yyyy}-{0000}, 1st invoice'); // counter must start to 1
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
print __METHOD__." result2=".$result."\n";
|
||||
$result3=$localobject->validate($user, $result); // create invoice by forcing ref
|
||||
$result3 = $localobject->validate($user, $result); // create invoice by forcing ref
|
||||
print __METHOD__." result3=".$result."\n";
|
||||
$this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok'); // counter must start to 1
|
||||
$result=$localobject->is_erasable();
|
||||
$result = $localobject->is_erasable();
|
||||
print __METHOD__." is_erasable=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(1, $result, 'Test for is_erasable, 1st invoice'); // Can be deleted
|
||||
|
||||
$localobject2=new Facture($db);
|
||||
$localobject2 = new Facture($db);
|
||||
$localobject2->initAsSpecimen();
|
||||
$localobject2->fetch_thirdparty();
|
||||
|
||||
$localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1916); // we use following year for second invoice (there is no reset into mask)
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject2, 'last');
|
||||
$localobject2->date = dol_mktime(12, 0, 0, 1, 1, 1916); // we use following year for second invoice (there is no reset into mask)
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject2, 'last');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1915-0001', $result, "Test to get last value with param 'last'");
|
||||
$result=$numbering->getNextValue($mysoc, $localobject2);
|
||||
$result = $numbering->getNextValue($mysoc, $localobject2);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1916-0002', $result); // counter must be now 2 (not reset)
|
||||
$result2=$localobject2->create($user, 1);
|
||||
$result2 = $localobject2->create($user, 1);
|
||||
print __METHOD__." result2=".$result."\n";
|
||||
$result3=$localobject2->validate($user, $result); // create invoice by forcing ref
|
||||
$result3 = $localobject2->validate($user, $result); // create invoice by forcing ref
|
||||
print __METHOD__." result3=".$result."\n";
|
||||
$this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok'); // counter must start to 1
|
||||
$result=$localobject2->is_erasable();
|
||||
$result = $localobject2->is_erasable();
|
||||
print __METHOD__." is_erasable=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(1, $result); // Can be deleted
|
||||
$result=$localobject->is_erasable();
|
||||
$result = $localobject->is_erasable();
|
||||
print __METHOD__." is_erasable=".$result."\n";
|
||||
$this->assertLessThanOrEqual(0, $result, 'Test for {yyyy}-{0000} that is_erasable is 0 for 1st invoice'); // 1 can no more be deleted (2 is more recent)
|
||||
|
||||
// Now we try with a reset
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000@1}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000@1}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}-{0000@1}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}-{0000@1}';
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1910); // we use year 1910 to be sure to not have existing invoice for this year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1910); // we use year 1910 to be sure to not have existing invoice for this year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1910-0001', $result, 'Test for {yyyy}-{0000@1} 1st invoice'); // counter must start to 1
|
||||
|
||||
$localobject2=new Facture($db);
|
||||
$localobject2 = new Facture($db);
|
||||
$localobject2->initAsSpecimen();
|
||||
$localobject2->fetch_thirdparty();
|
||||
|
||||
$localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1910); // we use same year for second invoice (and there is a reset required)
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject2);
|
||||
$localobject2->date = dol_mktime(12, 0, 0, 1, 1, 1910); // we use same year for second invoice (and there is a reset required)
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject2);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1910-0002', $result, 'Test for {yyyy}-{0000@1} 2nd invoice, same day'); // counter must be now 2
|
||||
|
||||
$localobject3=new Facture($db);
|
||||
$localobject3 = new Facture($db);
|
||||
$localobject3->initAsSpecimen();
|
||||
$localobject3->fetch_thirdparty();
|
||||
|
||||
$localobject3->date=dol_mktime(12, 0, 0, 1, 1, 1911); // we use next year for third invoice (and there is a reset required)
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject3);
|
||||
$localobject3->date = dol_mktime(12, 0, 0, 1, 1, 1911); // we use next year for third invoice (and there is a reset required)
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject3);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('1911-0001', $result, 'Test for {yyyy}-{0000@1} 3rd invoice, same day'); // counter must be now 1
|
||||
|
||||
// Same but we add month after year
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@1}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@1}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@1}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@1}';
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1920); // we use year 1920 to be sure to not have existing invoice for this year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1920); // we use year 1920 to be sure to not have existing invoice for this year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('192001-0001', $result, 'Test for {yyyy}{mm}-{0000@1} 1st invoice'); // counter must start to 1
|
||||
$result=$localobject->is_erasable();
|
||||
$result = $localobject->is_erasable();
|
||||
print __METHOD__." is_erasable=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(1, $result); // Can be deleted
|
||||
|
||||
$localobject2=new Facture($db);
|
||||
$localobject2 = new Facture($db);
|
||||
$localobject2->initAsSpecimen();
|
||||
$localobject2->fetch_thirdparty();
|
||||
|
||||
$localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1921); // we use following year for second invoice (and there is a reset required)
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject2);
|
||||
$result2=$localobject2->create($user, 1);
|
||||
$result3=$localobject2->validate($user, $result);
|
||||
$localobject2->date = dol_mktime(12, 0, 0, 1, 1, 1921); // we use following year for second invoice (and there is a reset required)
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject2);
|
||||
$result2 = $localobject2->create($user, 1);
|
||||
$result3 = $localobject2->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('192101-0001', $result); // counter must be reset to 1
|
||||
$result=$localobject2->is_erasable();
|
||||
$result = $localobject2->is_erasable();
|
||||
print __METHOD__." is_erasable=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(1, $result); // Can be deleted
|
||||
$result=$localobject->is_erasable();
|
||||
$result = $localobject->is_erasable();
|
||||
print __METHOD__." is_erasable=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(1, $result); // Case 1 can be deleted (because there was a reset for case 2)
|
||||
|
||||
// Same but we add month before year and use a year on 2 digits
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT='[mm}{yy}-{0000@1}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE='{mm}{yy}-{0000@1}';
|
||||
$localobject=new Facture($db);
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT = '[mm}{yy}-{0000@1}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{mm}{yy}-{0000@1}';
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1925); // we use year 1925 to be sure to not have existing invoice for this year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1925); // we use year 1925 to be sure to not have existing invoice for this year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('0125-0001', $result, 'Test for {mm}{yy}-{0000@1} 1st invoice'); // counter must start to 1
|
||||
$result=$localobject->is_erasable(); // This call get getNextNumRef with param 'last'
|
||||
$result = $localobject->is_erasable(); // This call get getNextNumRef with param 'last'
|
||||
print __METHOD__." is_erasable=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(1, $result); // Can be deleted
|
||||
|
||||
$localobject2=new Facture($db);
|
||||
$localobject2 = new Facture($db);
|
||||
$localobject2->initAsSpecimen();
|
||||
$localobject2->fetch_thirdparty();
|
||||
$localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1925); // we use same year 1925 for second invoice (and there is a reset required)
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject2);
|
||||
$result2=$localobject2->create($user, 1);
|
||||
$result3=$localobject2->validate($user, $result);
|
||||
$localobject2->date = dol_mktime(12, 0, 0, 1, 1, 1925); // we use same year 1925 for second invoice (and there is a reset required)
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject2);
|
||||
$result2 = $localobject2->create($user, 1);
|
||||
$result3 = $localobject2->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('0125-0002', $result, 'Test for {mm}{yy}-{0000@1} 2nd invoice'); // counter must be now 2
|
||||
$result=$localobject2->is_erasable();
|
||||
$result = $localobject2->is_erasable();
|
||||
print __METHOD__." is_erasable=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(1, $result); // Can be deleted
|
||||
$result=$localobject->is_erasable();
|
||||
$result = $localobject->is_erasable();
|
||||
print __METHOD__." is_erasable=".$result."\n";
|
||||
$this->assertLessThanOrEqual(0, $result); // Case 1 can not be deleted (because there is an invoice 2)
|
||||
|
||||
$localobject3=new Facture($db);
|
||||
$localobject3 = new Facture($db);
|
||||
$localobject3->initAsSpecimen();
|
||||
$localobject3->fetch_thirdparty();
|
||||
$localobject3->date=dol_mktime(12, 0, 0, 1, 1, 1926); // we use following year for third invoice (and there is a reset required)
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject3);
|
||||
$localobject3->date = dol_mktime(12, 0, 0, 1, 1, 1926); // we use following year for third invoice (and there is a reset required)
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject3);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('0126-0001', $result, 'Test for {mm}{yy}-{0000@1} 3rd invoice'); // counter must be now 1
|
||||
|
||||
// Try an offset when an invoice already exists
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000+9990}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000+9990}';
|
||||
$result=$numbering->getNextValue($mysoc, $localobject2);
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000+9990}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000+9990}';
|
||||
$result = $numbering->getNextValue($mysoc, $localobject2);
|
||||
|
||||
// Now we try with a different fiscal month (forced by mask)
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@6}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@6}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@6}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@6}';
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1930); // we use year 1930 to be sure to not have existing invoice for this year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject, 'last');
|
||||
$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1930); // we use year 1930 to be sure to not have existing invoice for this year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject, 'last');
|
||||
print __METHOD__." result for last=".$result."\n";
|
||||
$this->assertEquals('', $result); // no existing ref into reset range
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('193001-0001', $result); // counter must start to 1
|
||||
$result=$numbering->getNextValue($mysoc, $localobject, 'last');
|
||||
$result = $numbering->getNextValue($mysoc, $localobject, 'last');
|
||||
print __METHOD__." result for last=".$result."\n";
|
||||
$this->assertEquals('193001-0001', $result); // last ref into reset range should be same than last created
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1930); // we use same year but fiscal month after
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject, 'last');
|
||||
$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1930); // we use same year but fiscal month after
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject, 'last');
|
||||
print __METHOD__." result for last=".$result."\n";
|
||||
$this->assertEquals('', $result); // last ref into reset range should be ''
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('193012-0001', $result); // counter must be reset to 1
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1931); // we use same fiscal year but different year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1931); // we use same fiscal year but different year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('193101-0002', $result); // counter must be 2
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1931); // we use different fiscal year but same year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1931); // we use different fiscal year but same year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('193112-0001', $result); // counter must be reset to 1
|
||||
|
||||
|
||||
// Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START)
|
||||
$conf->global->SOCIETE_FISCAL_MONTH_START=6;
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@0}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@0}';
|
||||
$conf->global->SOCIETE_FISCAL_MONTH_START = 6;
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@0}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@0}';
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1940); // we use year 1940 to be sure to not have existing invoice for this year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1940); // we use year 1940 to be sure to not have existing invoice for this year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('194001-0001', $result); // counter must start to 1
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1940); // we use same year but fiscal month after
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1940); // we use same year but fiscal month after
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('194012-0001', $result); // counter must be reset to 1
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1941); // we use same fiscal year but different year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1941); // we use same fiscal year but different year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('194101-0002', $result); // counter must be 2
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1941); // we use different discal year but same year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1941); // we use different discal year but same year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('194112-0001', $result); // counter must be reset to 1
|
||||
|
||||
|
||||
// Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want year of element
|
||||
$conf->global->SOCIETE_FISCAL_MONTH_START=6;
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@=}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@=}';
|
||||
$conf->global->SOCIETE_FISCAL_MONTH_START = 6;
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@=}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@=}';
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1950); // we use year 1950 to be sure to not have existing invoice for this year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1950); // we use year 1950 to be sure to not have existing invoice for this year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('195001-0001', $result); // counter must start to 1
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1950); // we use same year but fiscal month after
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1950); // we use same year but fiscal month after
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('195012-0001', $result); // counter must be reset to 1
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1951); // we use same fiscal year but different year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1951); // we use same fiscal year but different year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('195101-0002', $result); // counter must be 2
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1951); // we use different discal year but same year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1951); // we use different discal year but same year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('195112-0001', $result); // counter must be reset to 1
|
||||
|
||||
|
||||
// Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want start year
|
||||
$conf->global->SOCIETE_FISCAL_MONTH_START=6;
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@-}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@-}';
|
||||
$conf->global->SOCIETE_FISCAL_MONTH_START = 6;
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@-}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@-}';
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1960); // we use year 1960 to be sure to not have existing invoice for this year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1960); // we use year 1960 to be sure to not have existing invoice for this year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('195901-0001', $result); // counter must start to 1
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1960); // we use same year but fiscal month after
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1960); // we use same year but fiscal month after
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('196012-0001', $result); // counter must be reset to 1
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1961); // we use same fiscal year but different year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1961); // we use same fiscal year but different year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('196001-0002', $result); // counter must be 2
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1961); // we use different discal year but same year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1961); // we use different discal year but same year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('196112-0001', $result); // counter must be reset to 1
|
||||
|
||||
|
||||
// Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want end year
|
||||
$conf->global->SOCIETE_FISCAL_MONTH_START=6;
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@+}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@+}';
|
||||
$conf->global->SOCIETE_FISCAL_MONTH_START = 6;
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@+}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@+}';
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1970); // we use year 1970 to be sure to not have existing invoice for this year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1970); // we use year 1970 to be sure to not have existing invoice for this year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('197001-0001', $result); // counter must start to 1
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1970); // we use same year but fiscal month after
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1970); // we use same year but fiscal month after
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('197112-0001', $result); // counter must be reset to 1
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1971); // we use same fiscal year but different year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1971); // we use same fiscal year but different year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('197101-0002', $result); // counter must be 2
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1971); // we use different fiscal year but same year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1971); // we use different fiscal year but same year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('197212-0001', $result); // counter must be reset to 1
|
||||
|
||||
// Now we try with a reset every month (@99)
|
||||
$conf->global->SOCIETE_FISCAL_MONTH_START=6;
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@99}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@99}';
|
||||
$conf->global->SOCIETE_FISCAL_MONTH_START = 6;
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@99}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@99}';
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('198001-0001', $result); // counter must start to 1
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('198001-0002', $result); // counter must start to 2
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 2, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 2, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('198002-0001', $result); // counter must start to 1
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1981); // we use year 1981 to be sure to not have existing invoice for this year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1981); // we use year 1981 to be sure to not have existing invoice for this year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('198101-0001', $result); // counter must start to 1
|
||||
|
||||
// Test with {t} tag
|
||||
$conf->global->SOCIETE_FISCAL_MONTH_START=1;
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT='{t}{yyyy}{mm}-{0000}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE='{t}{yyyy}{mm}-{0000}';
|
||||
$conf->global->SOCIETE_FISCAL_MONTH_START = 1;
|
||||
$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{t}{yyyy}{mm}-{0000}';
|
||||
$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{t}{yyyy}{mm}-{0000}';
|
||||
|
||||
$tmpthirdparty=new Societe($db);
|
||||
$tmpthirdparty = new Societe($db);
|
||||
$tmpthirdparty->initAsSpecimen();
|
||||
$tmpthirdparty->typent_code = 'TE_ABC';
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1982); // we use year 1982 to be sure to not have existing invoice for this year
|
||||
$numbering=new mod_facture_mercure();
|
||||
$result=$numbering->getNextValue($tmpthirdparty, $localobject);
|
||||
$result2=$localobject->create($user, 1);
|
||||
$result3=$localobject->validate($user, $result);
|
||||
$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1982); // we use year 1982 to be sure to not have existing invoice for this year
|
||||
$numbering = new mod_facture_mercure();
|
||||
$result = $numbering->getNextValue($tmpthirdparty, $localobject);
|
||||
$result2 = $localobject->create($user, 1);
|
||||
$result3 = $localobject->validate($user, $result);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('A198201-0001', $result); // counter must start to 1
|
||||
|
||||
@@ -589,21 +589,21 @@ class NumberingModulesTest extends CommonClassTest
|
||||
public function testShipmentSafor()
|
||||
{
|
||||
global $conf,$user,$langs,$db,$mysoc;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
require_once dirname(__FILE__).'/../../htdocs/expedition/class/expedition.class.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/expedition/mod_expedition_safor.php';
|
||||
|
||||
$localobject=new Expedition($db);
|
||||
$localobject = new Expedition($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->fetch_thirdparty();
|
||||
|
||||
$localobject->date_creation = dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1915 to be sure to not have existing invoice for this year (useful only if numbering is {0000@1}
|
||||
$numbering=new mod_expedition_safor();
|
||||
$result=$numbering->getNextValue($mysoc, $localobject);
|
||||
$numbering = new mod_expedition_safor();
|
||||
$result = $numbering->getNextValue($mysoc, $localobject);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('SH8001-0003', $result); // counter must start to 1
|
||||
|
||||
@@ -35,7 +35,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
$langs->load("main");
|
||||
|
||||
@@ -57,10 +57,10 @@ class ODFTest extends CommonClassTest
|
||||
public function testODFconvertVarToOdf()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// we test using template_invoice, it does not matter, we just need a valid odt.
|
||||
$filename = '../../htdocs/install/doctemplates/invoices/template_invoice.odt';
|
||||
@@ -283,7 +283,7 @@ class ODFTest extends CommonClassTest
|
||||
],
|
||||
];
|
||||
|
||||
$odf=new Odf($filename, array());
|
||||
$odf = new Odf($filename, array());
|
||||
if (is_object($odf)) {
|
||||
$result = 1;
|
||||
} // Just to test
|
||||
|
||||
@@ -37,7 +37,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -77,15 +77,15 @@ class PaypalTest extends CommonClassTest
|
||||
public function testPaypalOk()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$urltotest=getOnlinePaymentUrl(0, 'free');
|
||||
$urltotest = getOnlinePaymentUrl(0, 'free');
|
||||
print "urltotest=".$urltotest."\n";
|
||||
|
||||
$result=getURLContent($urltotest, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||
$result = getURLContent($urltotest, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||
|
||||
print __METHOD__." result=".$result['http_code']."\n";
|
||||
$this->assertEquals(200, $result['http_code']);
|
||||
|
||||
@@ -40,7 +40,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -60,12 +60,12 @@ class PdfDocTest extends CommonClassTest
|
||||
public function testPdfDocGetLineDesc()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localproduct=new Product($db);
|
||||
$localproduct = new Product($db);
|
||||
$result = $localproduct->fetch(0, 'PINKDRESS');
|
||||
if ($result < 0) {
|
||||
print "\n".__METHOD__." Failed to make the fetch of product PINKDRESS. ".$localproduct->error;
|
||||
@@ -77,19 +77,19 @@ class PdfDocTest extends CommonClassTest
|
||||
die(1);
|
||||
}
|
||||
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->lines=array();
|
||||
$localobject->lines[0]=new FactureLigne($db);
|
||||
$localobject->lines[0]->fk_product=$product_id;
|
||||
$localobject->lines[0]->label='Label 1';
|
||||
$localobject->lines[0]->desc="This is a description with a é accent\n(Country of origin: France)";
|
||||
$localobject->lines = array();
|
||||
$localobject->lines[0] = new FactureLigne($db);
|
||||
$localobject->lines[0]->fk_product = $product_id;
|
||||
$localobject->lines[0]->label = 'Label 1';
|
||||
$localobject->lines[0]->desc = "This is a description with a é accent\n(Country of origin: France)";
|
||||
|
||||
$result=pdf_getlinedesc($localobject, 0, $langs);
|
||||
$result = pdf_getlinedesc($localobject, 0, $langs);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals("PINKDRESS - Label 1<br>This is a description with a é accent<br>(Country of origin: France)", $result);
|
||||
|
||||
$result=doc_getlinedesc($localobject->lines[0], $langs);
|
||||
$result = doc_getlinedesc($localobject->lines[0], $langs);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals("PINKDRESS - Label 1\nThis is a description with a é accent\n(Country of origin: France)", $result);
|
||||
}
|
||||
@@ -101,12 +101,12 @@ class PdfDocTest extends CommonClassTest
|
||||
*/
|
||||
public function testPdfGetHeightForLogo()
|
||||
{
|
||||
$file=dirname(__FILE__).'/img250x50.jpg';
|
||||
$result=pdf_getHeightForLogo($file);
|
||||
$file = dirname(__FILE__).'/img250x50.jpg';
|
||||
$result = pdf_getHeightForLogo($file);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, 20);
|
||||
$file=dirname(__FILE__).'/img250x20.png';
|
||||
$result=pdf_getHeightForLogo($file);
|
||||
$file = dirname(__FILE__).'/img250x20.png';
|
||||
$result = pdf_getHeightForLogo($file);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, 10.4);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ if (empty($user->id)) {
|
||||
$user->getrights();
|
||||
}
|
||||
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -59,10 +59,10 @@ class PgsqlTest extends CommonClassTest
|
||||
public function testConvertSQLFromMysql()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// Create a dummy db handler for pgsql
|
||||
$tmpdb = new DoliDBPgsql('pqsql', 'host', 'user', 'pass');
|
||||
@@ -75,50 +75,50 @@ class PgsqlTest extends CommonClassTest
|
||||
*/
|
||||
|
||||
$sql = "ALTER TABLE llx_bank_account MODIFY COLUMN state_id integer USING state_id::integer;";
|
||||
$result=$tmpdb->convertSQLFromMysql($sql);
|
||||
$result = $tmpdb->convertSQLFromMysql($sql);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, "-- ALTER TABLE llx_bank_account MODIFY COLUMN state_id integer USING state_id::integer; replaced by --\nALTER TABLE llx_bank_account ALTER COLUMN state_id TYPE integer USING state_id::integer;");
|
||||
|
||||
$sql="ALTER TABLE llx_table RENAME TO llx_table_new;";
|
||||
$result=$tmpdb->convertSQLFromMysql($sql);
|
||||
$sql = "ALTER TABLE llx_table RENAME TO llx_table_new;";
|
||||
$result = $tmpdb->convertSQLFromMysql($sql);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, "ALTER TABLE llx_table RENAME TO llx_table_new;");
|
||||
|
||||
$sql="ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol;";
|
||||
$result=$tmpdb->convertSQLFromMysql($sql);
|
||||
$sql = "ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol;";
|
||||
$result = $tmpdb->convertSQLFromMysql($sql);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, "ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0';");
|
||||
|
||||
$sql="ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60);";
|
||||
$result=$tmpdb->convertSQLFromMysql($sql);
|
||||
$sql = "ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60);";
|
||||
$result = $tmpdb->convertSQLFromMysql($sql);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, "-- ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); replaced by --\nALTER TABLE llx_table RENAME COLUMN oldname TO newname");
|
||||
|
||||
$sql="ALTER TABLE llx_table DROP COLUMN oldname;";
|
||||
$result=$tmpdb->convertSQLFromMysql($sql);
|
||||
$sql = "ALTER TABLE llx_table DROP COLUMN oldname;";
|
||||
$result = $tmpdb->convertSQLFromMysql($sql);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, $sql);
|
||||
|
||||
$sql="ALTER TABLE llx_table MODIFY name varchar(60);";
|
||||
$result=$tmpdb->convertSQLFromMysql($sql);
|
||||
$sql = "ALTER TABLE llx_table MODIFY name varchar(60);";
|
||||
$result = $tmpdb->convertSQLFromMysql($sql);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, "-- ALTER TABLE llx_table MODIFY name varchar(60); replaced by --\nALTER TABLE llx_table ALTER COLUMN name TYPE varchar(60);");
|
||||
|
||||
// Create a constraint
|
||||
$sql='ALTER TABLE llx_tablechild ADD CONSTRAINT fk_tablechild_fk_fieldparent FOREIGN KEY (fk_fieldparent) REFERENCES llx_tableparent (rowid)';
|
||||
$result=$tmpdb->convertSQLFromMysql($sql);
|
||||
$sql = 'ALTER TABLE llx_tablechild ADD CONSTRAINT fk_tablechild_fk_fieldparent FOREIGN KEY (fk_fieldparent) REFERENCES llx_tableparent (rowid)';
|
||||
$result = $tmpdb->convertSQLFromMysql($sql);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, $sql.' DEFERRABLE INITIALLY IMMEDIATE;');
|
||||
|
||||
// Test GROUP_CONCAT (without SEPARATOR)
|
||||
$sql="SELECT a.b, GROUP_CONCAT(a.c) FROM table GROUP BY a.b";
|
||||
$result=$tmpdb->convertSQLFromMysql($sql);
|
||||
$sql = "SELECT a.b, GROUP_CONCAT(a.c) FROM table GROUP BY a.b";
|
||||
$result = $tmpdb->convertSQLFromMysql($sql);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, "SELECT a.b, STRING_AGG(a.c, ',') FROM table GROUP BY a.b", 'Test GROUP_CONCAT (without SEPARATOR)');
|
||||
|
||||
// Test GROUP_CONCAT (with SEPARATOR)
|
||||
$sql="SELECT a.b, GROUP_CONCAT(a.c SEPARATOR ',') FROM table GROUP BY a.b";
|
||||
$result=$tmpdb->convertSQLFromMysql($sql);
|
||||
$sql = "SELECT a.b, GROUP_CONCAT(a.c SEPARATOR ',') FROM table GROUP BY a.b";
|
||||
$result = $tmpdb->convertSQLFromMysql($sql);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($result, "SELECT a.b, STRING_AGG(a.c, ',') FROM table GROUP BY a.b", 'Test GROUP_CONCAT (with SEPARATOR)');
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
if (getDolGlobalString('MAIN_ROUNDING_RULE_TOT')) {
|
||||
print "Parameter MAIN_ROUNDING_RULE_TOT must be set to 0 or not set.\n";
|
||||
@@ -63,38 +63,38 @@ class PricesTest extends CommonClassTest
|
||||
public function testCalculPriceTotal()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
$this->savconf = $conf;
|
||||
$this->savuser = $user;
|
||||
$this->savlangs = $langs;
|
||||
$this->savdb = $db;
|
||||
|
||||
global $mysoc;
|
||||
$mysoc=new Societe($db);
|
||||
$mysoc = new Societe($db);
|
||||
|
||||
/*
|
||||
* Country France
|
||||
*/
|
||||
|
||||
// qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT' (method we provide value)
|
||||
$mysoc->country_code='FR';
|
||||
$mysoc->country_id=1;
|
||||
$result1=calcul_price_total(1, 1.24, 0, 10, 0, 0, 0, 'HT', 0, 0);
|
||||
$mysoc->country_code = 'FR';
|
||||
$mysoc->country_id = 1;
|
||||
$result1 = calcul_price_total(1, 1.24, 0, 10, 0, 0, 0, 'HT', 0, 0);
|
||||
print __METHOD__." result1=".join(', ', $result1)."\n";
|
||||
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
|
||||
$this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0, 1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0), $result1, 'Test1 FR');
|
||||
|
||||
// qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value)
|
||||
$mysoc->country_code='FR';
|
||||
$mysoc->country_id=1;
|
||||
$result1=calcul_price_total(2, 8.56, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205);
|
||||
$mysoc->country_code = 'FR';
|
||||
$mysoc->country_id = 1;
|
||||
$result1 = calcul_price_total(2, 8.56, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205);
|
||||
print __METHOD__." result1=".join(', ', $result1)."\n";
|
||||
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
|
||||
$this->assertEquals(array(17.12, 1.71, 18.83, 8.56, 0.856, 9.416, 17.12, 1.71, 18.83, 0, 0, 0, 0, 0, 0, 0, 18.7, 1.87, 20.57, 9.34795, 0.93479, 10.28274, 18.7, 1.87, 20.57, 0, 0), $result1, 'Test1b FR');
|
||||
|
||||
// qty=2, unit_price=0, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value), pu_ht_devise=100
|
||||
$mysoc->country_code='FR';
|
||||
$mysoc->country_id=1;
|
||||
$result1=calcul_price_total(2, 0, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205, 20);
|
||||
$mysoc->country_code = 'FR';
|
||||
$mysoc->country_id = 1;
|
||||
$result1 = calcul_price_total(2, 0, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205, 20);
|
||||
print __METHOD__." result1=".join(', ', $result1)."\n";
|
||||
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
|
||||
$this->assertEquals(array(36.63, 3.66, 40.29, 18.31418, 1.83142, 20.1456, 36.63, 3.66, 40.29, 0, 0, 0, 0, 0, 0, 0, 40, 4, 44, 20, 2, 22, 40, 4, 44, 0, 0), $result1, 'Test1c FR');
|
||||
@@ -104,21 +104,21 @@ class PricesTest extends CommonClassTest
|
||||
*/
|
||||
|
||||
// 10 * 10 HT - 0% discount with 10% vat, seller not using localtax1, not localtax2 (method we provide value)
|
||||
$mysoc->country_code='ES';
|
||||
$mysoc->country_id=4;
|
||||
$mysoc->localtax1_assuj=0;
|
||||
$mysoc->localtax2_assuj=0;
|
||||
$result2=calcul_price_total(10, 10, 0, 10, 0, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2
|
||||
$mysoc->country_code = 'ES';
|
||||
$mysoc->country_id = 4;
|
||||
$mysoc->localtax1_assuj = 0;
|
||||
$mysoc->localtax2_assuj = 0;
|
||||
$result2 = calcul_price_total(10, 10, 0, 10, 0, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2
|
||||
print __METHOD__." result2=".join(', ', $result2)."\n";
|
||||
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
|
||||
$this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0), $result2, 'Test1 ES');
|
||||
|
||||
// 10 * 10 HT - 0% discount with 10% vat, seller not using localtax1, not localtax2 (other method autodetect)
|
||||
$mysoc->country_code='ES';
|
||||
$mysoc->country_id=4;
|
||||
$mysoc->localtax1_assuj=0;
|
||||
$mysoc->localtax2_assuj=0;
|
||||
$result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2
|
||||
$mysoc->country_code = 'ES';
|
||||
$mysoc->country_id = 4;
|
||||
$mysoc->localtax1_assuj = 0;
|
||||
$mysoc->localtax2_assuj = 0;
|
||||
$result2 = calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2
|
||||
print __METHOD__." result2=".join(', ', $result2)."\n";
|
||||
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
|
||||
$this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0), $result2, 'Test2 ES');
|
||||
@@ -126,21 +126,21 @@ class PricesTest extends CommonClassTest
|
||||
// --------------------------------------------------------
|
||||
|
||||
// 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (method we provide value)
|
||||
$mysoc->country_code='ES';
|
||||
$mysoc->country_id=4;
|
||||
$mysoc->localtax1_assuj=1;
|
||||
$mysoc->localtax2_assuj=0;
|
||||
$result2=calcul_price_total(10, 10, 0, 10, 1.4, 0, 0, 'HT', 0, 0);
|
||||
$mysoc->country_code = 'ES';
|
||||
$mysoc->country_id = 4;
|
||||
$mysoc->localtax1_assuj = 1;
|
||||
$mysoc->localtax2_assuj = 0;
|
||||
$result2 = calcul_price_total(10, 10, 0, 10, 1.4, 0, 0, 'HT', 0, 0);
|
||||
print __METHOD__." result2=".join(', ', $result2)."\n";
|
||||
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
|
||||
$this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0), $result2, 'Test3 ES');
|
||||
|
||||
// 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect)
|
||||
$mysoc->country_code='ES';
|
||||
$mysoc->country_id=4;
|
||||
$mysoc->localtax1_assuj=1;
|
||||
$mysoc->localtax2_assuj=0;
|
||||
$result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0);
|
||||
$mysoc->country_code = 'ES';
|
||||
$mysoc->country_id = 4;
|
||||
$mysoc->localtax1_assuj = 1;
|
||||
$mysoc->localtax2_assuj = 0;
|
||||
$result2 = calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0);
|
||||
print __METHOD__." result2=".join(', ', $result2)."\n";
|
||||
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
|
||||
$this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0), $result2, 'Test4 ES');
|
||||
@@ -148,30 +148,30 @@ class PricesTest extends CommonClassTest
|
||||
// --------------------------------------------------------
|
||||
|
||||
// 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 19% localtax2 type 5 (method we provide value), we provide a service and not a product
|
||||
$mysoc->country_code='ES';
|
||||
$mysoc->country_id=4;
|
||||
$mysoc->localtax1_assuj=0;
|
||||
$mysoc->localtax2_assuj=1;
|
||||
$result2=calcul_price_total(10, 10, 0, 10, 0, -19, 0, 'HT', 0, 1);
|
||||
$mysoc->country_code = 'ES';
|
||||
$mysoc->country_id = 4;
|
||||
$mysoc->localtax1_assuj = 0;
|
||||
$mysoc->localtax2_assuj = 1;
|
||||
$result2 = calcul_price_total(10, 10, 0, 10, 0, -19, 0, 'HT', 0, 1);
|
||||
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
|
||||
$this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19), $result2, 'Test5 ES for service');
|
||||
|
||||
// 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (other method autodetect), we provide a service and not a product
|
||||
$mysoc->country_code='ES';
|
||||
$mysoc->country_id=4;
|
||||
$mysoc->localtax1_assuj=0;
|
||||
$mysoc->localtax2_assuj=1;
|
||||
$result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0);
|
||||
$mysoc->country_code = 'ES';
|
||||
$mysoc->country_id = 4;
|
||||
$mysoc->localtax1_assuj = 0;
|
||||
$mysoc->localtax2_assuj = 1;
|
||||
$result2 = calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0);
|
||||
print __METHOD__." result2=".join(', ', $result2)."\n";
|
||||
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
|
||||
$this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0), $result2, 'Test6 ES for product');
|
||||
|
||||
// 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (other method autodetect), we provide a product and not a service
|
||||
$mysoc->country_code='ES';
|
||||
$mysoc->country_id=4;
|
||||
$mysoc->localtax1_assuj=0;
|
||||
$mysoc->localtax2_assuj=1;
|
||||
$result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 1);
|
||||
$mysoc->country_code = 'ES';
|
||||
$mysoc->country_id = 4;
|
||||
$mysoc->localtax1_assuj = 0;
|
||||
$mysoc->localtax2_assuj = 1;
|
||||
$result2 = calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 1);
|
||||
print __METHOD__." result2=".join(', ', $result2)."\n";
|
||||
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
|
||||
$this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19), $result2, 'Test6 ES for service');
|
||||
@@ -179,21 +179,21 @@ class PricesTest extends CommonClassTest
|
||||
// --------------------------------------------------------
|
||||
|
||||
// Credit Note: 10 * -10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 19% localtax2 type 5 (method we provide value), we provide a product and not a service
|
||||
$mysoc->country_code='ES';
|
||||
$mysoc->country_id=4;
|
||||
$mysoc->localtax1_assuj=0;
|
||||
$mysoc->localtax2_assuj=1;
|
||||
$result2=calcul_price_total(10, -10, 0, 10, 0, 19, 0, 'HT', 0, 0);
|
||||
$mysoc->country_code = 'ES';
|
||||
$mysoc->country_id = 4;
|
||||
$mysoc->localtax1_assuj = 0;
|
||||
$mysoc->localtax2_assuj = 1;
|
||||
$result2 = calcul_price_total(10, -10, 0, 10, 0, 19, 0, 'HT', 0, 0);
|
||||
print __METHOD__." result2=".join(', ', $result2)."\n";
|
||||
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
|
||||
$this->assertEquals(array(-100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0, 0, 0, 0, 0, 0, -100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0), $result2, 'Test7 ES for product');
|
||||
|
||||
// Credit Note: 10 * -10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect), we provide a service and not a product
|
||||
$mysoc->country_code='ES';
|
||||
$mysoc->country_id=4;
|
||||
$mysoc->localtax1_assuj=0;
|
||||
$mysoc->localtax2_assuj=1;
|
||||
$result2=calcul_price_total(10, -10, 0, 10, -1, -1, 0, 'HT', 0, 1);
|
||||
$mysoc->country_code = 'ES';
|
||||
$mysoc->country_id = 4;
|
||||
$mysoc->localtax1_assuj = 0;
|
||||
$mysoc->localtax2_assuj = 1;
|
||||
$result2 = calcul_price_total(10, -10, 0, 10, -1, -1, 0, 'HT', 0, 1);
|
||||
print __METHOD__." result2=".join(', ', $result2)."\n";
|
||||
$this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19, 0, 1.90, 0, 0, 19, -100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19), $result2, 'Test8 ES for service');
|
||||
|
||||
@@ -203,23 +203,23 @@ class PricesTest extends CommonClassTest
|
||||
*/
|
||||
|
||||
// 10 * 10 HT - 0% discount with 18% vat, seller using localtax1 type 2, not localtax2 (method we provide value)
|
||||
$mysoc->country_code='CI';
|
||||
$mysoc->country_id=21;
|
||||
$mysoc->localtax1_assuj=1;
|
||||
$mysoc->localtax2_assuj=0;
|
||||
$mysoc->country_code = 'CI';
|
||||
$mysoc->country_id = 21;
|
||||
$mysoc->localtax1_assuj = 1;
|
||||
$mysoc->localtax2_assuj = 0;
|
||||
//$localtaxes=getLocalTaxesFromRate(18, 0, null, $mysoc);
|
||||
//var_dump($locataxes);
|
||||
$result3=calcul_price_total(10, 10, 0, 18, 7.5, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2
|
||||
$result3 = calcul_price_total(10, 10, 0, 18, 7.5, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2
|
||||
print __METHOD__." result3=".join(', ', $result3)."\n";
|
||||
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
|
||||
$this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0), $result3, 'Test9 CI');
|
||||
|
||||
// 10 * 10 HT - 0% discount with 18% vat, seller using localtax1 type 2, not localtax2 (other method autodetect)
|
||||
$mysoc->country_code='CI';
|
||||
$mysoc->country_id=21;
|
||||
$mysoc->localtax1_assuj=1;
|
||||
$mysoc->localtax2_assuj=0;
|
||||
$result3=calcul_price_total(10, 10, 0, 18, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2
|
||||
$mysoc->country_code = 'CI';
|
||||
$mysoc->country_id = 21;
|
||||
$mysoc->localtax1_assuj = 1;
|
||||
$mysoc->localtax2_assuj = 0;
|
||||
$result3 = calcul_price_total(10, 10, 0, 18, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2
|
||||
print __METHOD__." result3=".join(', ', $result3)."\n";
|
||||
// result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
|
||||
$this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0), $result3, 'Test10 CI');
|
||||
@@ -238,22 +238,22 @@ class PricesTest extends CommonClassTest
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
$this->savconf = $conf;
|
||||
$this->savuser = $user;
|
||||
$this->savlangs = $langs;
|
||||
$this->savdb = $db;
|
||||
|
||||
$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0;
|
||||
$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0;
|
||||
|
||||
// Two lines of 1.24 give 2.48 HT and 2.72 TTC with standard vat rounding mode
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen('nolines');
|
||||
$invoiceid=$localobject->create($user);
|
||||
$invoiceid = $localobject->create($user);
|
||||
|
||||
$localobject->addline('Desc', 1.24, 1, 10, 0, 0, 0, 0, '', '', 0, 0, 0, 'HT');
|
||||
$localobject->addline('Desc', 1.24, 1, 10, 0, 0, 0, 0, '', '', 0, 0, 0, 'HT');
|
||||
|
||||
$newlocalobject=new Facture($db);
|
||||
$newlocalobject = new Facture($db);
|
||||
$newlocalobject->fetch($invoiceid);
|
||||
|
||||
$this->assertEquals(2.48, $newlocalobject->total_ht, "testUpdatePrice test1");
|
||||
@@ -262,14 +262,14 @@ class PricesTest extends CommonClassTest
|
||||
|
||||
|
||||
// Two lines of 1.24 give 2.48 HT and 2.73 TTC with global vat rounding mode
|
||||
$localobject=new Facture($db);
|
||||
$localobject = new Facture($db);
|
||||
$localobject->initAsSpecimen('nolines');
|
||||
$invoiceid=$localobject->create($user);
|
||||
$invoiceid = $localobject->create($user);
|
||||
|
||||
$localobject->addline('Desc', 1.24, 1, 10, 0, 0, 0, 0, '', '', 0, 0, 0, 'HT');
|
||||
$localobject->addline('Desc', 1.24, 1, 10, 0, 0, 0, 0, '', '', 0, 0, 0, 'HT');
|
||||
|
||||
$newlocalobject=new Facture($db);
|
||||
$newlocalobject = new Facture($db);
|
||||
$newlocalobject->fetch($invoiceid);
|
||||
|
||||
$this->assertEquals(2.48, $newlocalobject->total_ht, "testUpdatePrice test4");
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -76,14 +76,14 @@ class ProductTest extends CommonClassTest
|
||||
public function testProductCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Product($db);
|
||||
$localobject = new Product($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThanOrEqual($result, 0, "Creation of product");
|
||||
@@ -103,13 +103,13 @@ class ProductTest extends CommonClassTest
|
||||
public function testProductFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Product($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Product($db);
|
||||
$result = $localobject->fetch($id);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -128,14 +128,14 @@ class ProductTest extends CommonClassTest
|
||||
public function testProductUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->note_public = 'New public note after update';
|
||||
$localobject->note_private = 'New private note after update';
|
||||
$result=$localobject->update($localobject->id, $user);
|
||||
$result = $localobject->update($localobject->id, $user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, 'Error '.$localobject->error);
|
||||
|
||||
@@ -154,10 +154,10 @@ class ProductTest extends CommonClassTest
|
||||
public function testProductOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$this->assertEquals(0, 0);
|
||||
|
||||
@@ -176,15 +176,15 @@ class ProductTest extends CommonClassTest
|
||||
public function testProductDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Product($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Product($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$result=$localobject->delete($user);
|
||||
$result = $localobject->delete($user);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -57,14 +57,14 @@ class ProjectTest extends CommonClassTest
|
||||
public function testProjectCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Project($db);
|
||||
$localobject = new Project($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -83,13 +83,13 @@ class ProjectTest extends CommonClassTest
|
||||
public function testProjectFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Project($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Project($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
@@ -108,12 +108,12 @@ class ProjectTest extends CommonClassTest
|
||||
public function testProjectValid($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->setValid($user);
|
||||
$result = $localobject->setValid($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -132,12 +132,12 @@ class ProjectTest extends CommonClassTest
|
||||
public function testProjectOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->setClose($user);
|
||||
$result = $localobject->setClose($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -156,14 +156,14 @@ class ProjectTest extends CommonClassTest
|
||||
public function testProjectDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Project($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new Project($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,14 +56,14 @@ class PropalTest extends CommonClassTest
|
||||
public function testPropalCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Propal($db);
|
||||
$localobject = new Propal($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -82,13 +82,13 @@ class PropalTest extends CommonClassTest
|
||||
public function testPropalFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Propal($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Propal($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
@@ -107,10 +107,10 @@ class PropalTest extends CommonClassTest
|
||||
public function testPropalUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->note_private = 'New note private after update';
|
||||
$result = $localobject->update($user);
|
||||
@@ -132,13 +132,13 @@ class PropalTest extends CommonClassTest
|
||||
public function testPropalAddLine($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->fetch_thirdparty();
|
||||
$result=$localobject->addline('Added line', 10, 2, 19.6);
|
||||
$result = $localobject->addline('Added line', 10, 2, 19.6);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
@@ -157,12 +157,12 @@ class PropalTest extends CommonClassTest
|
||||
public function testPropalValid($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->valid($user);
|
||||
$result = $localobject->valid($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -181,10 +181,10 @@ class PropalTest extends CommonClassTest
|
||||
public function testPropalOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
/*$result=$localobject->setstatus(0);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
@@ -210,14 +210,14 @@ class PropalTest extends CommonClassTest
|
||||
public function testPropalDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Propal($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new Propal($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -37,7 +37,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
/**
|
||||
* Class for PHPUnit tests
|
||||
@@ -56,10 +56,10 @@ class ReceptionTest extends CommonClassTest
|
||||
public function testReceptionCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$soc = new Societe($db);
|
||||
$soc->name = "ReceptionTest Unittest";
|
||||
|
||||
@@ -67,7 +67,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -91,12 +91,12 @@ class RepositoryTest extends CommonClassTest
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
// Scan dir to guarantee we don't have library jquery twice
|
||||
$foundfiles=dol_dir_list(DOL_DOCUMENT_ROOT.'/includes/', 'files', 1, '^jquery\.js', array('ckeditor'));
|
||||
$foundfiles = dol_dir_list(DOL_DOCUMENT_ROOT.'/includes/', 'files', 1, '^jquery\.js', array('ckeditor'));
|
||||
print __METHOD__." count(founddirs)=".count($foundfiles)."\n";
|
||||
$this->assertEquals(1, count($foundfiles), 'We found jquery lib (jquery.js) twice');
|
||||
|
||||
// Scan dir to guarantee we don't have library jquery twice
|
||||
$foundfiles=dol_dir_list(DOL_DOCUMENT_ROOT.'/includes/', 'files', 1, '^jquery\.min\.js', array('ckeditor'));
|
||||
$foundfiles = dol_dir_list(DOL_DOCUMENT_ROOT.'/includes/', 'files', 1, '^jquery\.min\.js', array('ckeditor'));
|
||||
print __METHOD__." count(founddirs)=".count($foundfiles)."\n";
|
||||
$this->assertEquals(1, count($foundfiles), 'We found jquery lib (jquery.min.js) twice '.(empty($foundfiles[0]) ? '' : $foundfiles[0]['fullname']).' '.(empty($foundfiles[1]) ? '' : $foundfiles[1]['fullname']));
|
||||
}
|
||||
@@ -110,10 +110,10 @@ class RepositoryTest extends CommonClassTest
|
||||
public function testRepository()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
$filesarray = dol_dir_list(DOL_DOCUMENT_ROOT, 'directories', 1, '', array('\/custom\/'), 'fullname', SORT_ASC, 0, 1, '', 1);
|
||||
|
||||
@@ -37,8 +37,8 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_UMASK='0666';
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
$conf->global->MAIN_UMASK = '0666';
|
||||
|
||||
|
||||
/**
|
||||
@@ -79,19 +79,19 @@ class RestAPIContactTest extends CommonClassTest
|
||||
protected function setUp(): void
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$this->api_url = DOL_MAIN_URL_ROOT.'/api/index.php';
|
||||
|
||||
$login='admin';
|
||||
$password='admin';
|
||||
$url=$this->api_url.'/login?login='.$login.'&password='.$password;
|
||||
$login = 'admin';
|
||||
$password = 'admin';
|
||||
$url = $this->api_url.'/login?login='.$login.'&password='.$password;
|
||||
// Call the API login method to save api_key for this test class.
|
||||
// At first call, if token is not defined a random value is generated and returned.
|
||||
$result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||
$result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||
print __METHOD__." result = ".var_export($result, true)."\n";
|
||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals($result['curl_error_no'], '');
|
||||
@@ -124,7 +124,7 @@ class RestAPIContactTest extends CommonClassTest
|
||||
print __METHOD__." result for get on unexisting contact: ".var_export($result, true)."\n";
|
||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals($result['curl_error_no'], '');
|
||||
$object=json_decode($result['content'], true);
|
||||
$object = json_decode($result['content'], true);
|
||||
$this->assertNotNull($object, "Parsing of json result must not be null");
|
||||
$this->assertEquals(404, $object['error']['code'], 'Error code is not 404');
|
||||
|
||||
@@ -132,11 +132,11 @@ class RestAPIContactTest extends CommonClassTest
|
||||
$url = $this->api_url.'/contacts/1?api_key='.$this->api_key;
|
||||
|
||||
print __METHOD__." Request GET url=".$url."\n";
|
||||
$result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||
$result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||
print __METHOD__." result for get on an existing contact: ".var_export($result, true)."\n";
|
||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals($result['curl_error_no'], '');
|
||||
$object=json_decode($result['content'], true);
|
||||
$object = json_decode($result['content'], true);
|
||||
$this->assertNotNull($object, "Parsing of json result must not be null");
|
||||
$this->assertEquals(1, $object['statut']);
|
||||
}
|
||||
@@ -154,16 +154,16 @@ class RestAPIContactTest extends CommonClassTest
|
||||
global $conf,$user,$langs,$db;
|
||||
// attempt to create without mandatory fields
|
||||
$url = $this->api_url.'/contacts?api_key='.$this->api_key;
|
||||
$addheaders=array('Content-Type: application/json');
|
||||
$addheaders = array('Content-Type: application/json');
|
||||
|
||||
$bodyobj= array(
|
||||
$bodyobj = array(
|
||||
"firstname" => "firstname"
|
||||
);
|
||||
|
||||
$body = json_encode($bodyobj);
|
||||
|
||||
//print __METHOD__." Request POST url=".$url."\n";
|
||||
$result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
|
||||
$result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
|
||||
//print __METHOD__." Result for creating incomplete contact".var_export($result, true)."\n";
|
||||
//print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals($result['curl_error_no'], '');
|
||||
@@ -209,7 +209,7 @@ class RestAPIContactTest extends CommonClassTest
|
||||
global $conf,$user,$langs,$db;
|
||||
// attempt to create without mandatory fields
|
||||
$url = $this->api_url.'/contacts?api_key='.$this->api_key;
|
||||
$addheaders=array('Content-Type: application/json');
|
||||
$addheaders = array('Content-Type: application/json');
|
||||
|
||||
//update the contact
|
||||
|
||||
|
||||
@@ -85,12 +85,12 @@ class RestAPIDocumentTest extends CommonClassTest
|
||||
|
||||
$this->api_url = DOL_MAIN_URL_ROOT.'/api/index.php';
|
||||
|
||||
$login='admin';
|
||||
$password='admin';
|
||||
$url=$this->api_url.'/login?login='.$login.'&password='.$password;
|
||||
$login = 'admin';
|
||||
$password = 'admin';
|
||||
$url = $this->api_url.'/login?login='.$login.'&password='.$password;
|
||||
// Call the API login method to save api_key for this test class.
|
||||
// At first call, if token is not defined a random value is generated and returned.
|
||||
$result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||
$result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||
print __METHOD__." result = ".var_export($result, true)."\n";
|
||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals($result['curl_error_no'], '');
|
||||
@@ -125,13 +125,13 @@ class RestAPIDocumentTest extends CommonClassTest
|
||||
|
||||
//$data = '{ "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "" }';
|
||||
$data = array(
|
||||
'filename'=>"mynewfile.txt",
|
||||
'modulepart'=>"medias",
|
||||
'subdir'=>"tmpphpunit/tmpphpunit1",
|
||||
'filecontent'=>"content text",
|
||||
'fileencoding'=>"",
|
||||
'overwriteifexists'=>0,
|
||||
'createdirifnotexists'=>0
|
||||
'filename' => "mynewfile.txt",
|
||||
'modulepart' => "medias",
|
||||
'subdir' => "tmpphpunit/tmpphpunit1",
|
||||
'filecontent' => "content text",
|
||||
'fileencoding' => "",
|
||||
'overwriteifexists' => 0,
|
||||
'createdirifnotexists' => 0
|
||||
);
|
||||
|
||||
$param = '';
|
||||
@@ -154,14 +154,14 @@ class RestAPIDocumentTest extends CommonClassTest
|
||||
dol_mkdir(DOL_DATA_ROOT.'/medias/tmpphpunit/tmpphpunit2');
|
||||
|
||||
$data = array(
|
||||
'filename'=>"mynewfile.txt",
|
||||
'modulepart'=>"medias",
|
||||
'ref'=>"",
|
||||
'subdir'=>"tmpphpunit/tmpphpunit2",
|
||||
'filecontent'=>"content text",
|
||||
'fileencoding'=>"",
|
||||
'overwriteifexists'=>0,
|
||||
'createdirifnotexists'=>0
|
||||
'filename' => "mynewfile.txt",
|
||||
'modulepart' => "medias",
|
||||
'ref' => "",
|
||||
'subdir' => "tmpphpunit/tmpphpunit2",
|
||||
'filecontent' => "content text",
|
||||
'fileencoding' => "",
|
||||
'overwriteifexists' => 0,
|
||||
'createdirifnotexists' => 0
|
||||
);
|
||||
|
||||
$param = '';
|
||||
@@ -182,14 +182,14 @@ class RestAPIDocumentTest extends CommonClassTest
|
||||
dol_delete_dir_recursive(DOL_DATA_ROOT.'/medias/tmpphpunit/tmpphpunit3');
|
||||
|
||||
$data = array(
|
||||
'filename'=>"mynewfile.txt",
|
||||
'modulepart'=>"medias",
|
||||
'ref'=>"",
|
||||
'subdir'=>"tmpphpunit/tmpphpunit3",
|
||||
'filecontent'=>"content text",
|
||||
'fileencoding'=>"",
|
||||
'overwriteifexists'=>0,
|
||||
'createdirifnotexists'=>1
|
||||
'filename' => "mynewfile.txt",
|
||||
'modulepart' => "medias",
|
||||
'ref' => "",
|
||||
'subdir' => "tmpphpunit/tmpphpunit3",
|
||||
'filecontent' => "content text",
|
||||
'fileencoding' => "",
|
||||
'overwriteifexists' => 0,
|
||||
'createdirifnotexists' => 1
|
||||
);
|
||||
|
||||
$param = '';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2023 Alexandre Janniaux <alexandre.janniaux@gmail.com>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
*
|
||||
* 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
|
||||
@@ -37,8 +38,8 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_UMASK='0666';
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
$conf->global->MAIN_UMASK = '0666';
|
||||
|
||||
|
||||
/**
|
||||
@@ -79,26 +80,27 @@ class RestAPIUserTest extends CommonClassTest
|
||||
protected function setUp(): void
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$this->api_url = DOL_MAIN_URL_ROOT.'/api/index.php';
|
||||
|
||||
$login='admin';
|
||||
$password='admin';
|
||||
$url=$this->api_url.'/login?login='.$login.'&password='.$password;
|
||||
$test = "API Test Setup - ";
|
||||
$login = 'admin';
|
||||
$password = 'admin';
|
||||
$url = $this->api_url.'/login?login='.$login.'&password='.$password;
|
||||
// Call the API login method to save api_key for this test class.
|
||||
// At first call, if token is not defined a random value is generated and returned.
|
||||
$result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||
$result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||
print __METHOD__." result = ".var_export($result, true)."\n";
|
||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals($result['curl_error_no'], '');
|
||||
$this->assertEquals('', $result['curl_error_no'], "$test Should not have a curl error");
|
||||
$object = json_decode($result['content'], true); // If success content is just an id, if not an array
|
||||
|
||||
$this->assertNotNull($object, "Parsing of json result must not be null");
|
||||
$this->assertNotEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
|
||||
$this->assertNotNull($object, "$test Parsing of JSON result must not be null");
|
||||
$this->assertNotEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), "$test Error".(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
|
||||
$this->assertEquals('200', $object['success']['code']);
|
||||
|
||||
$this->api_key = $object['success']['token'];
|
||||
@@ -116,27 +118,29 @@ class RestAPIUserTest extends CommonClassTest
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
|
||||
$test = "Invalid User -";
|
||||
$url = $this->api_url.'/users/123456789?api_key='.$this->api_key;
|
||||
//$addheaders=array('Content-Type: application/json');
|
||||
|
||||
print __METHOD__." Request GET url=".$url."\n";
|
||||
$result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||
$result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||
//print __METHOD__." result for get on unexisting user: ".var_export($result, true)."\n";
|
||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals($result['curl_error_no'], '');
|
||||
$object=json_decode($result['content'], true);
|
||||
$this->assertNotNull($object, "Parsing of json result must not be null");
|
||||
$this->assertEquals(404, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error code is not 404');
|
||||
$this->assertEquals('', $result['curl_error_no'], "$test Should not have a curl error");
|
||||
$object = json_decode($result['content'], true);
|
||||
$this->assertNotNull($object, "$test Parsing of JSON result must not be null");
|
||||
$this->assertEquals(404, (empty($object['error']['code']) ? 0 : $object['error']['code']), "$test Error code is not 404");
|
||||
|
||||
$test = "Existing User -";
|
||||
$url = $this->api_url.'/users/1?api_key='.$this->api_key;
|
||||
|
||||
print __METHOD__." Request GET url=".$url."\n";
|
||||
$result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||
print __METHOD__." result for get on an existing user: ".var_export($result, true)."\n";
|
||||
$result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||
print __METHOD__." $test result for get: ".var_export($result, true)."\n";
|
||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals($result['curl_error_no'], '');
|
||||
$object=json_decode($result['content'], true);
|
||||
$this->assertNotNull($object, "Parsing of json result must not be null");
|
||||
$this->assertEquals('', $result['curl_error_no'], "$test should have no error");
|
||||
$object = json_decode($result['content'], true);
|
||||
$this->assertNotNull($object, "$test Parsing of JSON result must not be null");
|
||||
$this->assertEquals(1, $object['statut']);
|
||||
|
||||
return $object['id'];
|
||||
@@ -153,53 +157,56 @@ class RestAPIUserTest extends CommonClassTest
|
||||
public function testRestCreateUser()
|
||||
{
|
||||
// attempt to create without mandatory fields :
|
||||
$test = "Create User Missing Fields -";
|
||||
$url = $this->api_url.'/users?api_key='.$this->api_key;
|
||||
$addheaders=array('Content-Type: application/json');
|
||||
$addheaders = array('Content-Type: application/json');
|
||||
|
||||
$bodyobj = array(
|
||||
"lastname"=>"testRestUser",
|
||||
"password"=>"testRestPassword",
|
||||
"email"=>"test@restuser.com"
|
||||
"lastname" => "testRestUser",
|
||||
"password" => "testRestPassword",
|
||||
"email" => "test@restuser.com"
|
||||
);
|
||||
$body = json_encode($bodyobj);
|
||||
|
||||
print __METHOD__." Request POST url=".$url."\n";
|
||||
$result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
|
||||
$result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
|
||||
//print __METHOD__." Result for creating incomplete user".var_export($result, true)."\n";
|
||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals($result['curl_error_no'], '');
|
||||
$object=json_decode($result['content'], true);
|
||||
$this->assertNotNull($object, "Parsing of json result must no be null");
|
||||
$this->assertEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
|
||||
$this->assertEquals('', $result['curl_error_no'], "$test Should not have a curl error");
|
||||
$object = json_decode($result['content'], true);
|
||||
$this->assertNotNull($object, "$test Parsing of JSON result must not be null");
|
||||
$this->assertEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), "$test Error".(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
|
||||
|
||||
// create regular user
|
||||
$test = "Create Regular User -";
|
||||
unset($result);
|
||||
$bodyobj = array(
|
||||
"login"=>"testRestLogin".mt_rand(),
|
||||
"lastname"=>"testRestUser",
|
||||
"password"=>"testRestPassword",
|
||||
"email"=>"test".mt_rand()."@restuser.com"
|
||||
"login" => "testRestLogin".mt_rand(),
|
||||
"lastname" => "testRestUser",
|
||||
"password" => "testRestPassword",
|
||||
"email" => "test".mt_rand()."@restuser.com"
|
||||
);
|
||||
$body = json_encode($bodyobj);
|
||||
print __METHOD__." Request POST url=".$url."\n";
|
||||
$result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
|
||||
$result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
|
||||
print __METHOD__." result code for creating non existing user = ".var_export($result, true)."\n";
|
||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals($result['curl_error_no'], '');
|
||||
$this->assertEquals('', $result['curl_error_no'], "$test Should not have a curl error");
|
||||
$object = json_decode($result['content'], true); // If success content is just an id, if not an array
|
||||
|
||||
$this->assertNotNull($object, "Parsing of json result must no be null");
|
||||
$this->assertNotEquals(500, ((is_scalar($object) || empty($object['error']) || empty($object['error']['code'])) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
|
||||
$this->assertNotNull($object, "$test Parsing of JSON result must not be null");
|
||||
$this->assertNotEquals(500, ((is_scalar($object) || empty($object['error']) || empty($object['error']['code'])) ? 0 : $object['error']['code']), "$test Error".(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
|
||||
$this->assertGreaterThan(0, $object, 'ID returned is no > 0');
|
||||
|
||||
// attempt to create duplicated user
|
||||
$test = "Create Duplicate User -";
|
||||
print __METHOD__." Request POST url=".$url."\n";
|
||||
$result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
|
||||
$result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
|
||||
//print __METHOD__." Result for creating duplicate user".var_export($result, true)."\n";
|
||||
print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
|
||||
$this->assertEquals($result['curl_error_no'], '');
|
||||
$object=json_decode($result['content'], true);
|
||||
$this->assertNotNull($object, "Parsing of json result must no be null");
|
||||
$this->assertEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
|
||||
$this->assertEquals('', $result['curl_error_no'], "$test Should not have a curl error");
|
||||
$object = json_decode($result['content'], true);
|
||||
$this->assertNotNull($object, "$test Parsing of JSON result must not be null");
|
||||
$this->assertEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), "$test Error".(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -88,17 +88,17 @@ class ScriptsTest extends CommonClassTest
|
||||
public function testBank()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$script=dirname(__FILE__).'/../../scripts/bank/export-bank-receipts.php BANKDUMMY RECEIPTDUMMY excel2007 lang=fr_FR';
|
||||
$script = dirname(__FILE__).'/../../scripts/bank/export-bank-receipts.php BANKDUMMY RECEIPTDUMMY excel2007 lang=fr_FR';
|
||||
|
||||
$returnvar = 0;
|
||||
$output = array();
|
||||
|
||||
$result=exec($script, $output, $returnvar);
|
||||
$result = exec($script, $output, $returnvar);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." output=".join("\n", $output)."\n";
|
||||
@@ -118,10 +118,10 @@ class ScriptsTest extends CommonClassTest
|
||||
public function testCompany()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
/*
|
||||
$script=dirname(__FILE__).'/../../scripts/company/sync_contacts_dolibarr_2ldap now';
|
||||
@@ -147,30 +147,30 @@ class ScriptsTest extends CommonClassTest
|
||||
public function testContracts()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$returnvar = 0;
|
||||
$output = array();
|
||||
|
||||
$script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test thirdparties';
|
||||
$result=exec($script, $output, $returnvar);
|
||||
$script = dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test thirdparties';
|
||||
$result = exec($script, $output, $returnvar);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." output=".join("\n", $output)."\n";
|
||||
print __METHOD__." returnvar=".$returnvar."\n";
|
||||
$this->assertEquals($returnvar, 0, 'email_expire_services_to_customers.php thirdparties');
|
||||
|
||||
$script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test contacts -30';
|
||||
$result=exec($script, $output, $returnvar);
|
||||
$script = dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test contacts -30';
|
||||
$result = exec($script, $output, $returnvar);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." output=".join("\n", $output)."\n";
|
||||
print __METHOD__." returnvar=".$returnvar."\n";
|
||||
$this->assertEquals($returnvar, 0, 'email_expire_services_to_customers.php contacts');
|
||||
|
||||
$script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_representatives.php test -30';
|
||||
$result=exec($script, $output, $returnvar);
|
||||
$script = dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_representatives.php test -30';
|
||||
$result = exec($script, $output, $returnvar);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." output=".join("\n", $output)."\n";
|
||||
print __METHOD__." returnvar=".$returnvar."\n";
|
||||
@@ -188,30 +188,30 @@ class ScriptsTest extends CommonClassTest
|
||||
public function testInvoices()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$returnvar = 0;
|
||||
$output = array();
|
||||
|
||||
$script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test thirdparties';
|
||||
$result=exec($script, $output, $returnvar);
|
||||
$script = dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test thirdparties';
|
||||
$result = exec($script, $output, $returnvar);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." output=".join("\n", $output)."\n";
|
||||
print __METHOD__." returnvar=".$returnvar."\n";
|
||||
$this->assertEquals($returnvar, 0, 'email_unpaid_invoices_to_customers.php thirdparties');
|
||||
|
||||
$script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test contacts -30';
|
||||
$result=exec($script, $output, $returnvar);
|
||||
$script = dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test contacts -30';
|
||||
$result = exec($script, $output, $returnvar);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." output=".join("\n", $output)."\n";
|
||||
print __METHOD__." returnvar=".$returnvar."\n";
|
||||
$this->assertEquals($returnvar, 0, 'email_unpaid_invoices_to_customers.php contacts');
|
||||
|
||||
$script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_representatives.php test thirdparties';
|
||||
$result=exec($script, $output, $returnvar);
|
||||
$script = dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_representatives.php test thirdparties';
|
||||
$result = exec($script, $output, $returnvar);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." output=".join("\n", $output)."\n";
|
||||
print __METHOD__." returnvar=".$returnvar."\n";
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -38,7 +38,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -87,14 +87,14 @@ class SocieteTest extends CommonClassTest
|
||||
public function testSocieteCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Societe($db);
|
||||
$localobject = new Societe($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertLessThanOrEqual($result, 0);
|
||||
@@ -114,17 +114,17 @@ class SocieteTest extends CommonClassTest
|
||||
public function testSocieteFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Societe($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Societe($db);
|
||||
$result = $localobject->fetch($id);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
$result=$localobject->verify();
|
||||
$result = $localobject->verify();
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertEquals($result, 0);
|
||||
|
||||
@@ -143,42 +143,42 @@ class SocieteTest extends CommonClassTest
|
||||
public function testSocieteUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->note_private='New private note after update';
|
||||
$localobject->note_public='New public note after update';
|
||||
$localobject->name='New name';
|
||||
$localobject->address='New address';
|
||||
$localobject->zip='New zip';
|
||||
$localobject->town='New town';
|
||||
$localobject->country_id=2;
|
||||
$localobject->status=0;
|
||||
$localobject->phone='New tel';
|
||||
$localobject->fax='New fax';
|
||||
$localobject->email='newemail@newemail.com';
|
||||
$localobject->url='New url';
|
||||
$localobject->idprof1='new idprof1';
|
||||
$localobject->idprof2='new idprof2';
|
||||
$localobject->idprof3='new idprof3';
|
||||
$localobject->idprof4='new idprof4';
|
||||
$localobject->note_private = 'New private note after update';
|
||||
$localobject->note_public = 'New public note after update';
|
||||
$localobject->name = 'New name';
|
||||
$localobject->address = 'New address';
|
||||
$localobject->zip = 'New zip';
|
||||
$localobject->town = 'New town';
|
||||
$localobject->country_id = 2;
|
||||
$localobject->status = 0;
|
||||
$localobject->phone = 'New tel';
|
||||
$localobject->fax = 'New fax';
|
||||
$localobject->email = 'newemail@newemail.com';
|
||||
$localobject->url = 'New url';
|
||||
$localobject->idprof1 = 'new idprof1';
|
||||
$localobject->idprof2 = 'new idprof2';
|
||||
$localobject->idprof3 = 'new idprof3';
|
||||
$localobject->idprof4 = 'new idprof4';
|
||||
|
||||
$result=$localobject->update($localobject->id, $user);
|
||||
$result = $localobject->update($localobject->id, $user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
$result=$localobject->update_note($localobject->note_private, '_private');
|
||||
$result = $localobject->update_note($localobject->note_private, '_private');
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, 'Holiday::update_note (private) error');
|
||||
|
||||
$result=$localobject->update_note($localobject->note_public, '_public');
|
||||
$result = $localobject->update_note($localobject->note_public, '_public');
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0, 'Holiday::update_note (public) error');
|
||||
|
||||
$newobject=new Societe($db);
|
||||
$result=$newobject->fetch($localobject->id);
|
||||
$newobject = new Societe($db);
|
||||
$result = $newobject->fetch($localobject->id);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -215,42 +215,42 @@ class SocieteTest extends CommonClassTest
|
||||
public function testIdProfCheck($localobject)
|
||||
{
|
||||
// OK FR
|
||||
$localobject->country_code='FR';
|
||||
$localobject->idprof1=493861496;
|
||||
$localobject->idprof2=49386149600021;
|
||||
$result=$localobject->id_prof_check(1, $localobject); // Must be > 0
|
||||
$localobject->country_code = 'FR';
|
||||
$localobject->idprof1 = 493861496;
|
||||
$localobject->idprof2 = 49386149600021;
|
||||
$result = $localobject->id_prof_check(1, $localobject); // Must be > 0
|
||||
print __METHOD__." OK FR idprof1 result=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(1, $result);
|
||||
$result=$localobject->id_prof_check(2, $localobject); // Must be > 0
|
||||
$result = $localobject->id_prof_check(2, $localobject); // Must be > 0
|
||||
print __METHOD__." OK FR idprof2 result=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(1, $result);
|
||||
|
||||
// KO FR
|
||||
$localobject->country_code='FR';
|
||||
$localobject->idprof1='id1ko';
|
||||
$localobject->idprof2='id2ko';
|
||||
$result=$localobject->id_prof_check(1, $localobject); // Must be <= 0
|
||||
$localobject->country_code = 'FR';
|
||||
$localobject->idprof1 = 'id1ko';
|
||||
$localobject->idprof2 = 'id2ko';
|
||||
$result = $localobject->id_prof_check(1, $localobject); // Must be <= 0
|
||||
print __METHOD__." KO FR idprof1 result=".$result."\n";
|
||||
$this->assertLessThan(1, $result);
|
||||
$result=$localobject->id_prof_check(2, $localobject); // Must be <= 0
|
||||
$result = $localobject->id_prof_check(2, $localobject); // Must be <= 0
|
||||
print __METHOD__." KO FR idprof2 result=".$result."\n";
|
||||
$this->assertLessThan(1, $result);
|
||||
|
||||
// KO ES
|
||||
$localobject->country_code='ES';
|
||||
$localobject->idprof1='id1ko';
|
||||
$result=$localobject->id_prof_check(1, $localobject); // Must be <= 0
|
||||
$localobject->country_code = 'ES';
|
||||
$localobject->idprof1 = 'id1ko';
|
||||
$result = $localobject->id_prof_check(1, $localobject); // Must be <= 0
|
||||
print __METHOD__." KO ES idprof1 result=".$result."\n";
|
||||
$this->assertLessThan(1, $result);
|
||||
|
||||
// OK AR
|
||||
$localobject->country_code='AR';
|
||||
$localobject->idprof1='id1ko';
|
||||
$localobject->idprof2='id2ko';
|
||||
$result=$localobject->id_prof_check(1, $localobject); // Must be > 0
|
||||
$localobject->country_code = 'AR';
|
||||
$localobject->idprof1 = 'id1ko';
|
||||
$localobject->idprof2 = 'id2ko';
|
||||
$result = $localobject->id_prof_check(1, $localobject); // Must be > 0
|
||||
print __METHOD__." OK AR idprof1 result=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(0, $result);
|
||||
$result=$localobject->id_prof_check(2, $localobject); // Must be > 0
|
||||
$result = $localobject->id_prof_check(2, $localobject); // Must be > 0
|
||||
print __METHOD__." OK AR idprof2 result=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(1, $result);
|
||||
|
||||
@@ -270,36 +270,36 @@ class SocieteTest extends CommonClassTest
|
||||
public function testSocieteOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->setAsCustomer();
|
||||
$result = $localobject->setAsCustomer();
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
$result=$localobject->setPriceLevel(1, $user);
|
||||
$result = $localobject->setPriceLevel(1, $user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
$result=$localobject->set_remise_client(10, 'Gift', $user);
|
||||
$result = $localobject->set_remise_client(10, 'Gift', $user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
$result=$localobject->getNomUrl(1);
|
||||
$result = $localobject->getNomUrl(1);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertNotEquals($result, '');
|
||||
|
||||
$localobject->country_code = 'FR';
|
||||
|
||||
$result=$localobject->isInEEC();
|
||||
$result = $localobject->isInEEC();
|
||||
print __METHOD__." id=".$localobject->id." country_code=".$localobject->country_code." result=".$result."\n";
|
||||
$this->assertTrue($result);
|
||||
|
||||
$localobject->country_code = 'US';
|
||||
|
||||
$result=$localobject->isInEEC();
|
||||
$result = $localobject->isInEEC();
|
||||
print __METHOD__." id=".$localobject->id." country_code=".$localobject->country_code." result=".$result."\n";
|
||||
$this->assertFalse($result);
|
||||
|
||||
@@ -330,15 +330,15 @@ class SocieteTest extends CommonClassTest
|
||||
public function testGetOutstandingBills($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Societe($db);
|
||||
$localobject = new Societe($db);
|
||||
$localobject->fetch($id);
|
||||
|
||||
$result=$localobject->getOutstandingBills();
|
||||
$result = $localobject->getOutstandingBills();
|
||||
|
||||
print __METHOD__." id=".$id." result=".var_export($result, true)."\n";
|
||||
$this->assertTrue(array_key_exists('opened', $result), 'Result of getOutstandingBills failed');
|
||||
@@ -359,15 +359,15 @@ class SocieteTest extends CommonClassTest
|
||||
public function testSocieteDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Societe($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Societe($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$result=$localobject->delete($id, $user);
|
||||
$result = $localobject->delete($id, $user);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -383,56 +383,56 @@ class SocieteTest extends CommonClassTest
|
||||
public function testSocieteGetFullAddress()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobjectadd=new Societe($db);
|
||||
$localobjectadd = new Societe($db);
|
||||
$localobjectadd->initAsSpecimen();
|
||||
|
||||
// France
|
||||
unset($localobjectadd->country_code);
|
||||
$localobjectadd->country_id=1;
|
||||
$localobjectadd->name='New name';
|
||||
$localobjectadd->address='New address';
|
||||
$localobjectadd->zip='New zip';
|
||||
$localobjectadd->town='New town';
|
||||
$result=$localobjectadd->getFullAddress(1);
|
||||
$localobjectadd->country_id = 1;
|
||||
$localobjectadd->name = 'New name';
|
||||
$localobjectadd->address = 'New address';
|
||||
$localobjectadd->zip = 'New zip';
|
||||
$localobjectadd->town = 'New town';
|
||||
$result = $localobjectadd->getFullAddress(1);
|
||||
print __METHOD__." id=".$localobjectadd->id." result=".$result."\n";
|
||||
$this->assertStringContainsString("New address\nNew zip New town\nFrance", $result);
|
||||
|
||||
// Belgium
|
||||
unset($localobjectadd->country_code);
|
||||
$localobjectadd->country_id=2;
|
||||
$localobjectadd->name='New name';
|
||||
$localobjectadd->address='New address';
|
||||
$localobjectadd->zip='New zip';
|
||||
$localobjectadd->town='New town';
|
||||
$result=$localobjectadd->getFullAddress(1);
|
||||
$localobjectadd->country_id = 2;
|
||||
$localobjectadd->name = 'New name';
|
||||
$localobjectadd->address = 'New address';
|
||||
$localobjectadd->zip = 'New zip';
|
||||
$localobjectadd->town = 'New town';
|
||||
$result = $localobjectadd->getFullAddress(1);
|
||||
print __METHOD__." id=".$localobjectadd->id." result=".$result."\n";
|
||||
$this->assertStringContainsString("New address\nNew zip New town\nBelgium", $result);
|
||||
|
||||
// Switzerland
|
||||
unset($localobjectadd->country_code);
|
||||
$localobjectadd->country_id=6;
|
||||
$localobjectadd->name='New name';
|
||||
$localobjectadd->address='New address';
|
||||
$localobjectadd->zip='New zip';
|
||||
$localobjectadd->town='New town';
|
||||
$result=$localobjectadd->getFullAddress(1);
|
||||
$localobjectadd->country_id = 6;
|
||||
$localobjectadd->name = 'New name';
|
||||
$localobjectadd->address = 'New address';
|
||||
$localobjectadd->zip = 'New zip';
|
||||
$localobjectadd->town = 'New town';
|
||||
$result = $localobjectadd->getFullAddress(1);
|
||||
print __METHOD__." id=".$localobjectadd->id." result=".$result."\n";
|
||||
$this->assertStringContainsString("New address\nNew zip New town\nSwitzerland", $result);
|
||||
|
||||
// USA
|
||||
unset($localobjectadd->country_code);
|
||||
$localobjectadd->country_id=11;
|
||||
$localobjectadd->name='New name';
|
||||
$localobjectadd->address='New address';
|
||||
$localobjectadd->zip='New zip';
|
||||
$localobjectadd->town='New town';
|
||||
$localobjectadd->state='New state';
|
||||
$result=$localobjectadd->getFullAddress(1);
|
||||
$localobjectadd->country_id = 11;
|
||||
$localobjectadd->name = 'New name';
|
||||
$localobjectadd->address = 'New address';
|
||||
$localobjectadd->zip = 'New zip';
|
||||
$localobjectadd->town = 'New town';
|
||||
$localobjectadd->state = 'New state';
|
||||
$result = $localobjectadd->getFullAddress(1);
|
||||
print __METHOD__." id=".$localobjectadd->id." result=".$result."\n";
|
||||
$this->assertStringContainsString("New address\nNew town, New state, New zip\nUnited States", $result);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -77,15 +77,15 @@ class StripeTest extends CommonClassTest
|
||||
public function testStripeOk()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$urltotest=getOnlinePaymentUrl(0, 'free');
|
||||
$urltotest = getOnlinePaymentUrl(0, 'free');
|
||||
print "urltotest=".$urltotest."\n";
|
||||
|
||||
$result=getURLContent($urltotest, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||
$result = getURLContent($urltotest, 'GET', '', 1, array(), array('http', 'https'), 2);
|
||||
|
||||
print __METHOD__." result=".$result['http_code']."\n";
|
||||
$this->assertEquals(200, $result['http_code']);
|
||||
|
||||
@@ -39,7 +39,7 @@ if (empty($user->id)) {
|
||||
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -77,10 +77,10 @@ class SupplierProposalTest extends CommonClassTest
|
||||
protected function setUp(): void
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
//print $db->getVersion()."\n";
|
||||
@@ -98,14 +98,14 @@ class SupplierProposalTest extends CommonClassTest
|
||||
public function testSupplierProposalCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new SupplierProposal($db);
|
||||
$localobject = new SupplierProposal($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -124,13 +124,13 @@ class SupplierProposalTest extends CommonClassTest
|
||||
public function testSupplierProposalFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new SupplierProposal($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new SupplierProposal($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
@@ -149,13 +149,13 @@ class SupplierProposalTest extends CommonClassTest
|
||||
public function testSupplierProposalAddLine($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->fetch_thirdparty();
|
||||
$result=$localobject->addline('Added line', 10, 2, 19.6);
|
||||
$result = $localobject->addline('Added line', 10, 2, 19.6);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
@@ -174,10 +174,10 @@ class SupplierProposalTest extends CommonClassTest
|
||||
public function testSupplierProposalValid($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result = $user->addrights(0, 'supplier_proposal');
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -185,7 +185,7 @@ class SupplierProposalTest extends CommonClassTest
|
||||
$result = $user->getrights('supplier_proposal', 1);
|
||||
//$this->assertLessThan($result, 0);
|
||||
|
||||
$result=$localobject->valid($user);
|
||||
$result = $localobject->valid($user);
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
@@ -205,10 +205,10 @@ class SupplierProposalTest extends CommonClassTest
|
||||
public function testSupplierProposalOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
/*$result=$localobject->setstatus(0);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
@@ -234,14 +234,14 @@ class SupplierProposalTest extends CommonClassTest
|
||||
public function testSupplierProposalDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new SupplierProposal($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new SupplierProposal($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -85,13 +85,13 @@ class TargetTest extends CommonClassTest
|
||||
public function testTargetFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Target($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Target($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
@@ -114,7 +114,7 @@ class TargetTest extends CommonClassTest
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->note_private='New note private after update';
|
||||
$localobject->note_private = 'New note private after update';
|
||||
$result = $localobject->update($user);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -37,7 +37,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -57,24 +57,24 @@ class TicketTest extends CommonClassTest
|
||||
public function testTicketCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// Try to create one with bad values
|
||||
$localobject=new Ticket($db);
|
||||
$localobject = new Ticket($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->ref = '';
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(-3, $result, $localobject->error.join(',', $localobject->errors));
|
||||
|
||||
// Try to create one with correct values
|
||||
$localobject=new Ticket($db);
|
||||
$localobject = new Ticket($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result, $localobject->error.join(',', $localobject->errors));
|
||||
@@ -94,13 +94,13 @@ class TicketTest extends CommonClassTest
|
||||
public function testTicketFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Ticket($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new Ticket($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
@@ -120,12 +120,12 @@ class TicketTest extends CommonClassTest
|
||||
public function testTicketmarkAsRead($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->markAsRead($user);
|
||||
$result = $localobject->markAsRead($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertGreaterThan(0, $result);
|
||||
@@ -144,14 +144,14 @@ class TicketTest extends CommonClassTest
|
||||
public function testTicketsetProject($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$project_id = 1;
|
||||
|
||||
$result=$localobject->setProject($project_id);
|
||||
$result = $localobject->setProject($project_id);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertGreaterThan(0, $result);
|
||||
@@ -170,14 +170,14 @@ class TicketTest extends CommonClassTest
|
||||
public function testTicketsetContract($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$contract_id = 1;
|
||||
|
||||
$result=$localobject->setContract($contract_id);
|
||||
$result = $localobject->setContract($contract_id);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertGreaterThan(0, $result);
|
||||
@@ -196,14 +196,14 @@ class TicketTest extends CommonClassTest
|
||||
public function testTicketsetProgression($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$percent = 80;
|
||||
|
||||
$result=$localobject->setProgression($percent);
|
||||
$result = $localobject->setProgression($percent);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertGreaterThan(0, $result);
|
||||
@@ -222,14 +222,14 @@ class TicketTest extends CommonClassTest
|
||||
public function testTicketassignUser($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$user_id_to_assign = 1;
|
||||
|
||||
$result=$localobject->assignUser($user, $user_id_to_assign);
|
||||
$result = $localobject->assignUser($user, $user_id_to_assign);
|
||||
;
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
@@ -249,14 +249,14 @@ class TicketTest extends CommonClassTest
|
||||
public function testTicketassignUserOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$user_id_to_assign = 2;
|
||||
|
||||
$result=$localobject->assignUser($user, $user_id_to_assign);
|
||||
$result = $localobject->assignUser($user, $user_id_to_assign);
|
||||
;
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
@@ -276,12 +276,12 @@ class TicketTest extends CommonClassTest
|
||||
public function testTicketclose($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->close($user);
|
||||
$result = $localobject->close($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertGreaterThan(0, $result);
|
||||
@@ -301,14 +301,14 @@ class TicketTest extends CommonClassTest
|
||||
public function testTicketDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Ticket($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new Ticket($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result);
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,14 +56,14 @@ class UserGroupTest extends CommonClassTest
|
||||
public function testUserGroupCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new UserGroup($db);
|
||||
$localobject = new UserGroup($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -81,13 +81,13 @@ class UserGroupTest extends CommonClassTest
|
||||
public function testUserGroupFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new UserGroup($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new UserGroup($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
@@ -105,13 +105,13 @@ class UserGroupTest extends CommonClassTest
|
||||
public function testUserGroupUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject->note='New note after update';
|
||||
$result=$localobject->update($user);
|
||||
$localobject->note = 'New note after update';
|
||||
$result = $localobject->update($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -129,12 +129,12 @@ class UserGroupTest extends CommonClassTest
|
||||
public function testUserGroupAddRight($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->addrights(1, 'bookmarks');
|
||||
$result = $localobject->addrights(1, 'bookmarks');
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -152,12 +152,12 @@ class UserGroupTest extends CommonClassTest
|
||||
public function testUserGroupDelRight($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->delrights(1, 'bookmarks');
|
||||
$result = $localobject->delrights(1, 'bookmarks');
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -175,10 +175,10 @@ class UserGroupTest extends CommonClassTest
|
||||
public function testUserGroupOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result = $localobject->generateDocument('templatenamethadoesnotexist', $langs);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -198,14 +198,14 @@ class UserGroupTest extends CommonClassTest
|
||||
public function testUserGroupDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new UserGroup($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new UserGroup($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -75,16 +75,16 @@ class UserTest extends CommonClassTest
|
||||
public function testUserCreate()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
print __METHOD__." USER_PASSWORD_GENERATED=".getDolGlobalString('USER_PASSWORD_GENERATED')."\n";
|
||||
|
||||
$localobject=new User($db);
|
||||
$localobject = new User($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$result=$localobject->create($user);
|
||||
$result = $localobject->create($user);
|
||||
|
||||
$this->assertLessThan($result, 0, 'Creation of user has failed: '.$localobject->error);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
@@ -102,13 +102,13 @@ class UserTest extends CommonClassTest
|
||||
public function testUserFetch($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new User($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$localobject = new User($db);
|
||||
$result = $localobject->fetch($id);
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
@@ -126,19 +126,19 @@ class UserTest extends CommonClassTest
|
||||
public function testUserUpdate($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$this->changeProperties($localobject);
|
||||
$result=$localobject->update($user);
|
||||
$result = $localobject->update($user);
|
||||
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
// Test everything are still same than specimen
|
||||
$newlocalobject=new User($db);
|
||||
$newlocalobject = new User($db);
|
||||
$newlocalobject->initAsSpecimen();
|
||||
$this->changeProperties($newlocalobject);
|
||||
$this->assertEquals($this->objCompare($localobject, $newlocalobject, true, array('id','socid','societe_id','specimen','note','ref','pass','pass_indatabase','pass_indatabase_crypted','pass_temp','datec','datem','datelastlogin','datepreviouslogin','flagdelsessionsbefore','iplastlogin','ippreviouslogin','trackid')), array()); // Actual, Expected
|
||||
@@ -157,12 +157,12 @@ class UserTest extends CommonClassTest
|
||||
public function testUserDisable($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$result=$localobject->setstatus(0);
|
||||
$result = $localobject->setstatus(0);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -181,10 +181,10 @@ class UserTest extends CommonClassTest
|
||||
public function testUserOther($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
/*$result=$localobject->setstatus(0);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
@@ -207,10 +207,10 @@ class UserTest extends CommonClassTest
|
||||
public function testUserHasRight($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$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);
|
||||
@@ -239,10 +239,10 @@ class UserTest extends CommonClassTest
|
||||
public function testUserSetPassword($localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// Test the 'none' password generator
|
||||
|
||||
@@ -352,14 +352,14 @@ class UserTest extends CommonClassTest
|
||||
public function testUserDelete($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new User($db);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
$localobject = new User($db);
|
||||
$result = $localobject->fetch($id);
|
||||
$result = $localobject->delete($user);
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -377,14 +377,14 @@ class UserTest extends CommonClassTest
|
||||
public function testUserAddPermission($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new User($db);
|
||||
$result=$localobject->fetch(1); // Other tests use the user id 1
|
||||
$result=$localobject->addrights(0, 'supplier_proposal');
|
||||
$localobject = new User($db);
|
||||
$result = $localobject->fetch(1); // Other tests use the user id 1
|
||||
$result = $localobject->addrights(0, 'supplier_proposal');
|
||||
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@@ -401,7 +401,7 @@ class UserTest extends CommonClassTest
|
||||
*/
|
||||
public function changeProperties(&$localobject)
|
||||
{
|
||||
$localobject->note_private='New note after update';
|
||||
$localobject->note_private = 'New note after update';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -415,23 +415,23 @@ class UserTest extends CommonClassTest
|
||||
*/
|
||||
public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id'))
|
||||
{
|
||||
$retAr=array();
|
||||
$retAr = array();
|
||||
|
||||
if (get_class($oA) !== get_class($oB)) {
|
||||
$retAr[]="Supplied objects are not of same class.";
|
||||
$retAr[] = "Supplied objects are not of same class.";
|
||||
} else {
|
||||
$oVarsA=get_object_vars($oA);
|
||||
$oVarsB=get_object_vars($oB);
|
||||
$aKeys=array_keys($oVarsA);
|
||||
$oVarsA = get_object_vars($oA);
|
||||
$oVarsB = get_object_vars($oB);
|
||||
$aKeys = array_keys($oVarsA);
|
||||
foreach ($aKeys as $sKey) {
|
||||
if (in_array($sKey, $fieldstoignorearray)) {
|
||||
continue;
|
||||
}
|
||||
if (! $ignoretype && ($oVarsA[$sKey] !== $oVarsB[$sKey])) {
|
||||
$retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
|
||||
$retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
|
||||
}
|
||||
if ($ignoretype && ($oVarsA[$sKey] != $oVarsB[$sKey])) {
|
||||
$retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
|
||||
$retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,19 +56,19 @@ class UtilsTest extends CommonClassTest
|
||||
public function testExecuteCLI()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject=new Utils($db);
|
||||
$localobject = new Utils($db);
|
||||
$result = $localobject->executeCLI('ls', $conf->admin->dir_temp.'/out.tmp', 1);
|
||||
print var_export($result, true);
|
||||
$this->assertEquals($result['result'], 0);
|
||||
$this->assertEquals($result['error'], '');
|
||||
//$this->assertEquals(preg_match('/phpunit/', $result['output']), 1);
|
||||
|
||||
$localobject=new Utils($db);
|
||||
$localobject = new Utils($db);
|
||||
$result = $localobject->executeCLI('ls', $conf->admin->dir_temp.'/out.tmp', 2);
|
||||
print var_export($result, true);
|
||||
$this->assertEquals($result['result'], 0);
|
||||
|
||||
@@ -37,9 +37,9 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
$conf->global->MAIN_UMASK='0666';
|
||||
$conf->global->MAIN_UMASK = '0666';
|
||||
|
||||
|
||||
/**
|
||||
@@ -73,17 +73,17 @@ class WebservicesInvoicesTest extends CommonClassTest
|
||||
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
$this->savconf = $conf;
|
||||
$this->savuser = $user;
|
||||
$this->savlangs = $langs;
|
||||
$this->savdb = $db;
|
||||
|
||||
// Set the WebService URL
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php';
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$this->soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($this->soapclient) {
|
||||
$this->soapclient->soap_defencoding='UTF-8';
|
||||
$this->soapclient->soap_defencoding = 'UTF-8';
|
||||
$this->soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
@@ -116,18 +116,18 @@ class WebservicesInvoicesTest extends CommonClassTest
|
||||
// transaction commit. So if the invoice is created in the same
|
||||
// transaction than the third party, the FK constraint fails.
|
||||
// See this post for more detail: http://stackoverflow.com/a/5014744/5187108
|
||||
$societe=new Societe($db);
|
||||
$societe->ref='';
|
||||
$societe->name='name';
|
||||
$societe->ref_ext='ref-phpunit';
|
||||
$societe->status=1;
|
||||
$societe->client=1;
|
||||
$societe->code_client='CU0901-1234';
|
||||
$societe->code_fournisseur='SU0901-1234';
|
||||
$societe->fournisseur=0;
|
||||
$societe->date_creation=$now;
|
||||
$societe->tva_assuj=0;
|
||||
$societe->particulier=0;
|
||||
$societe = new Societe($db);
|
||||
$societe->ref = '';
|
||||
$societe->name = 'name';
|
||||
$societe->ref_ext = 'ref-phpunit';
|
||||
$societe->status = 1;
|
||||
$societe->client = 1;
|
||||
$societe->code_client = 'CU0901-1234';
|
||||
$societe->code_fournisseur = 'SU0901-1234';
|
||||
$societe->fournisseur = 0;
|
||||
$societe->date_creation = $now;
|
||||
$societe->tva_assuj = 0;
|
||||
$societe->particulier = 0;
|
||||
|
||||
$societe->create($user);
|
||||
if (empty($societe->id)) {
|
||||
@@ -153,10 +153,10 @@ class WebservicesInvoicesTest extends CommonClassTest
|
||||
public function testWSInvoicesCreateInvoice()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$WS_METHOD = 'createInvoice';
|
||||
|
||||
@@ -203,22 +203,22 @@ class WebservicesInvoicesTest extends CommonClassTest
|
||||
);
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>$this->pass,
|
||||
'entity'=>'');
|
||||
$authentication = array(
|
||||
'dolibarrkey' => getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication' => 'DEMO',
|
||||
'login' => 'admin',
|
||||
'password' => $this->pass,
|
||||
'entity' => '');
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication,'invoice'=>$body);
|
||||
$result = '';
|
||||
$parameters = array('authentication' => $authentication,'invoice' => $body);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $this->soapclient->call($WS_METHOD, $parameters, $this->ns, '');
|
||||
} catch (SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
$result = 0;
|
||||
}
|
||||
if (! $result || !empty($result['faultstring'])) {
|
||||
//var_dump($soapclient);
|
||||
@@ -250,30 +250,30 @@ class WebservicesInvoicesTest extends CommonClassTest
|
||||
public function testWSInvoicesGetInvoiceByRefExt($result)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$WS_METHOD = 'getInvoice';
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>$this->pass,
|
||||
'entity'=>'');
|
||||
$authentication = array(
|
||||
'dolibarrkey' => getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication' => 'DEMO',
|
||||
'login' => 'admin',
|
||||
'password' => $this->pass,
|
||||
'entity' => '');
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication, 'id'=>null, 'ref'=>null, 'ref_ext'=>'ref-phpunit-2');
|
||||
$result = '';
|
||||
$parameters = array('authentication' => $authentication, 'id' => null, 'ref' => null, 'ref_ext' => 'ref-phpunit-2');
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $this->soapclient->call($WS_METHOD, $parameters, $this->ns, '');
|
||||
} catch (SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
$result = 0;
|
||||
}
|
||||
if (! $result || !empty($result['faultstring'])) {
|
||||
print $this->soapclient->error_str;
|
||||
@@ -303,10 +303,10 @@ class WebservicesInvoicesTest extends CommonClassTest
|
||||
public function testWSInvoicesUpdateInvoiceByRefExt($result)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$WS_METHOD = 'updateInvoice';
|
||||
|
||||
@@ -355,22 +355,22 @@ class WebservicesInvoicesTest extends CommonClassTest
|
||||
);
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>$this->pass,
|
||||
'entity'=>'');
|
||||
$authentication = array(
|
||||
'dolibarrkey' => getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication' => 'DEMO',
|
||||
'login' => 'admin',
|
||||
'password' => $this->pass,
|
||||
'entity' => '');
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication,'invoice'=>$body);
|
||||
$result = '';
|
||||
$parameters = array('authentication' => $authentication,'invoice' => $body);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $this->soapclient->call($WS_METHOD, $parameters, $this->ns, '');
|
||||
} catch (SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
$result = 0;
|
||||
}
|
||||
if (! $result || !empty($result['faultstring'])) {
|
||||
print 'Error: '.$this->soapclient->error_str;
|
||||
|
||||
@@ -37,9 +37,9 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
$conf->global->MAIN_UMASK='0666';
|
||||
$conf->global->MAIN_UMASK = '0666';
|
||||
|
||||
|
||||
/**
|
||||
@@ -59,40 +59,40 @@ class WebservicesOrdersTest extends CommonClassTest
|
||||
public function testWSOrderGetOrder()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_order.php';
|
||||
$WS_METHOD = 'getOrder';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
$ns = 'http://www.dolibarr.org/ns/';
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient) {
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->soap_defencoding = 'UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>''
|
||||
$authentication = array(
|
||||
'dolibarrkey' => getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication' => 'DEMO',
|
||||
'login' => 'admin',
|
||||
'password' => 'admin',
|
||||
'entity' => ''
|
||||
);
|
||||
|
||||
// Test URL
|
||||
$parameters = array('authentication'=>$authentication,'id'=>1);
|
||||
$parameters = array('authentication' => $authentication,'id' => 1);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
|
||||
} catch (SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
$result = 0;
|
||||
}
|
||||
if (! $result || !empty($result['faultstring'])) {
|
||||
//var_dump($soapclient);
|
||||
|
||||
@@ -37,9 +37,9 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
$conf->global->MAIN_UMASK='0666';
|
||||
$conf->global->MAIN_UMASK = '0666';
|
||||
|
||||
|
||||
/**
|
||||
@@ -59,45 +59,45 @@ class WebservicesOtherTest extends CommonClassTest
|
||||
public function testWSOtherGetVersions()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_other.php';
|
||||
$WS_METHOD = 'getVersions';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
$ns = 'http://www.dolibarr.org/ns/';
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient) {
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->soap_defencoding = 'UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>''
|
||||
$authentication = array(
|
||||
'dolibarrkey' => getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication' => 'DEMO',
|
||||
'login' => 'admin',
|
||||
'password' => 'admin',
|
||||
'entity' => ''
|
||||
);
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication);
|
||||
$result = '';
|
||||
$parameters = array('authentication' => $authentication);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
|
||||
} catch (SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
$result = 0;
|
||||
}
|
||||
if (!empty($result['faultstring'])) {
|
||||
print $result['faultstring']."\n";
|
||||
$result=0;
|
||||
$result = 0;
|
||||
}
|
||||
if (! $result) {
|
||||
//var_dump($soapclient);
|
||||
@@ -113,15 +113,15 @@ class WebservicesOtherTest extends CommonClassTest
|
||||
$this->assertEquals('OK', $result['result']['result_code']);
|
||||
|
||||
// Test method that does not exists
|
||||
$WS_METHOD='methodthatdoesnotexists';
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication);
|
||||
$WS_METHOD = 'methodthatdoesnotexists';
|
||||
$result = '';
|
||||
$parameters = array('authentication' => $authentication);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
|
||||
} catch (SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
$result = 0;
|
||||
}
|
||||
if (! $result || !empty($result['faultstring'])) {
|
||||
//var_dump($soapclient);
|
||||
|
||||
@@ -39,9 +39,9 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
$conf->global->MAIN_UMASK='0666';
|
||||
$conf->global->MAIN_UMASK = '0666';
|
||||
|
||||
if (!isModEnabled('service')) {
|
||||
print "Error: Module service must be enabled.\n";
|
||||
@@ -65,47 +65,47 @@ class WebservicesProductsTest extends CommonClassTest
|
||||
public function testWSProductsCreateProductOrService()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$datestring=dol_print_date(dol_now(), 'dayhourlog');
|
||||
$datestring = dol_print_date(dol_now(), 'dayhourlog');
|
||||
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php';
|
||||
$WS_METHOD = 'createProductOrService';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
$ns = 'http://www.dolibarr.org/ns/';
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient) {
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->soap_defencoding = 'UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>''
|
||||
$authentication = array(
|
||||
'dolibarrkey' => getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication' => 'DEMO',
|
||||
'login' => 'admin',
|
||||
'password' => 'admin',
|
||||
'entity' => ''
|
||||
);
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$result = '';
|
||||
$parameters = array(
|
||||
'authentication'=>$authentication,'product'=>array(
|
||||
'ref'=>'NewProductFromWS'.$datestring,
|
||||
'label'=>'New Product From WS '.$datestring,
|
||||
'type'=>1,
|
||||
'description'=>'This is a new product created from WS PHPUnit test case',
|
||||
'barcode'=>'123456789012',
|
||||
'barcode_type'=>2,
|
||||
'price_net'=>10,
|
||||
'status_tosell'=>1,
|
||||
'status_tobuy'=>1
|
||||
'authentication' => $authentication,'product' => array(
|
||||
'ref' => 'NewProductFromWS'.$datestring,
|
||||
'label' => 'New Product From WS '.$datestring,
|
||||
'type' => 1,
|
||||
'description' => 'This is a new product created from WS PHPUnit test case',
|
||||
'barcode' => '123456789012',
|
||||
'barcode_type' => 2,
|
||||
'price_net' => 10,
|
||||
'status_tosell' => 1,
|
||||
'status_tobuy' => 1
|
||||
)
|
||||
);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
@@ -113,7 +113,7 @@ class WebservicesProductsTest extends CommonClassTest
|
||||
$result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
|
||||
} catch (SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
$result = 0;
|
||||
}
|
||||
if (! $result || !empty($result['faultstring']) || $result['result']['result_code'] != 'OK') {
|
||||
//var_dump($soapclient);
|
||||
@@ -142,41 +142,41 @@ class WebservicesProductsTest extends CommonClassTest
|
||||
public function testWSProductsGetProductOrService($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php';
|
||||
$WS_METHOD = 'getProductOrService';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
$ns = 'http://www.dolibarr.org/ns/';
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient) {
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->soap_defencoding = 'UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>''
|
||||
$authentication = array(
|
||||
'dolibarrkey' => getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication' => 'DEMO',
|
||||
'login' => 'admin',
|
||||
'password' => 'admin',
|
||||
'entity' => ''
|
||||
);
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication,'id'=>$id,'ref'=>'');
|
||||
$result = '';
|
||||
$parameters = array('authentication' => $authentication,'id' => $id,'ref' => '');
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
|
||||
} catch (SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
$result = 0;
|
||||
}
|
||||
if (! $result || !empty($result['faultstring'])) {
|
||||
//var_dump($soapclient);
|
||||
@@ -205,41 +205,41 @@ class WebservicesProductsTest extends CommonClassTest
|
||||
public function testWSProductsDeleteProductOrService($id)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php';
|
||||
$WS_METHOD = 'deleteProductOrService';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
$ns = 'http://www.dolibarr.org/ns/';
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient) {
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->soap_defencoding = 'UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>''
|
||||
$authentication = array(
|
||||
'dolibarrkey' => getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication' => 'DEMO',
|
||||
'login' => 'admin',
|
||||
'password' => 'admin',
|
||||
'entity' => ''
|
||||
);
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication,'listofid'=>$id);
|
||||
$result = '';
|
||||
$parameters = array('authentication' => $authentication,'listofid' => $id);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
|
||||
} catch (SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
$result = 0;
|
||||
}
|
||||
if (! $result || !empty($result['faultstring']) || $result['result']['result_code'] != 'OK') {
|
||||
//var_dump($soapclient);
|
||||
|
||||
@@ -37,9 +37,9 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
$conf->global->MAIN_UMASK='0666';
|
||||
$conf->global->MAIN_UMASK = '0666';
|
||||
|
||||
|
||||
/**
|
||||
@@ -53,7 +53,7 @@ class WebservicesThirdpartyTest extends CommonClassTest
|
||||
{
|
||||
protected $soapclient;
|
||||
|
||||
private $ns='http://www.dolibarr.org/ns/';
|
||||
private $ns = 'http://www.dolibarr.org/ns/';
|
||||
|
||||
|
||||
/**
|
||||
@@ -69,10 +69,10 @@ class WebservicesThirdpartyTest extends CommonClassTest
|
||||
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
$this->savconf = $conf;
|
||||
$this->savuser = $user;
|
||||
$this->savlangs = $langs;
|
||||
$this->savdb = $db;
|
||||
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php';
|
||||
|
||||
@@ -80,7 +80,7 @@ class WebservicesThirdpartyTest extends CommonClassTest
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$this->soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($this->soapclient) {
|
||||
$this->soapclient->soap_defencoding='UTF-8';
|
||||
$this->soapclient->soap_defencoding = 'UTF-8';
|
||||
$this->soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
@@ -98,21 +98,21 @@ class WebservicesThirdpartyTest extends CommonClassTest
|
||||
public function testWSThirdpartycreateThirdParty()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$WS_METHOD = 'createThirdParty';
|
||||
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>'');
|
||||
$authentication = array(
|
||||
'dolibarrkey' => getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication' => 'DEMO',
|
||||
'login' => 'admin',
|
||||
'password' => 'admin',
|
||||
'entity' => '');
|
||||
|
||||
$body = array(
|
||||
"id" => null,
|
||||
@@ -153,14 +153,14 @@ class WebservicesThirdpartyTest extends CommonClassTest
|
||||
);
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication, 'thirdparty'=>$body);
|
||||
$result = '';
|
||||
$parameters = array('authentication' => $authentication, 'thirdparty' => $body);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $this->soapclient->call($WS_METHOD, $parameters, $this->ns, '');
|
||||
} catch (SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
$result = 0;
|
||||
}
|
||||
if (! $result || !empty($result['faultstring'])) {
|
||||
//var_dump($soapclient);
|
||||
@@ -191,30 +191,30 @@ class WebservicesThirdpartyTest extends CommonClassTest
|
||||
public function testWSThirdpartygetThirdPartyById($result)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
$id = $result['id'];
|
||||
|
||||
$WS_METHOD = 'getThirdParty';
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>'');
|
||||
$authentication = array(
|
||||
'dolibarrkey' => getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication' => 'DEMO',
|
||||
'login' => 'admin',
|
||||
'password' => 'admin',
|
||||
'entity' => '');
|
||||
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication, 'id'=>$id);
|
||||
$result = '';
|
||||
$parameters = array('authentication' => $authentication, 'id' => $id);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $this->soapclient->call($WS_METHOD, $parameters, $this->ns, '');
|
||||
} catch (SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
$result = 0;
|
||||
}
|
||||
if (! $result || !empty($result['faultstring'])) {
|
||||
//var_dump($soapclient);
|
||||
@@ -252,31 +252,31 @@ class WebservicesThirdpartyTest extends CommonClassTest
|
||||
public function testWSThirdpartygetThirdPartyByRefExt($result)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
$id = $result['id'];
|
||||
|
||||
$WS_METHOD = 'getThirdParty';
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>'');
|
||||
$authentication = array(
|
||||
'dolibarrkey' => getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication' => 'DEMO',
|
||||
'login' => 'admin',
|
||||
'password' => 'admin',
|
||||
'entity' => '');
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication, 'id'=>'', 'ref'=>'', 'ref_ext'=>'12');
|
||||
$result = '';
|
||||
$parameters = array('authentication' => $authentication, 'id' => '', 'ref' => '', 'ref_ext' => '12');
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $this->soapclient->call($WS_METHOD, $parameters, $this->ns, '');
|
||||
} catch (SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
$result = 0;
|
||||
}
|
||||
print $this->soapclient->response;
|
||||
if (! $result || !empty($result['faultstring'])) {
|
||||
@@ -313,30 +313,30 @@ class WebservicesThirdpartyTest extends CommonClassTest
|
||||
public function testWSThirdpartydeleteThirdPartyById($result)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
$id = $result['id'];
|
||||
|
||||
$WS_METHOD = 'deleteThirdParty';
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>'');
|
||||
$authentication = array(
|
||||
'dolibarrkey' => getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication' => 'DEMO',
|
||||
'login' => 'admin',
|
||||
'password' => 'admin',
|
||||
'entity' => '');
|
||||
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication, 'id'=>$id, 'ref'=>'', 'ref_ext'=>'');
|
||||
$result = '';
|
||||
$parameters = array('authentication' => $authentication, 'id' => $id, 'ref' => '', 'ref_ext' => '');
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $this->soapclient->call($WS_METHOD, $parameters, $this->ns, '');
|
||||
} catch (SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
$result = 0;
|
||||
}
|
||||
if (! $result || !empty($result['faultstring'])) {
|
||||
print 'Error: '.$this->soapclient->error_str;
|
||||
|
||||
@@ -37,9 +37,9 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
$conf->global->MAIN_UMASK='0666';
|
||||
$conf->global->MAIN_UMASK = '0666';
|
||||
|
||||
|
||||
/**
|
||||
@@ -59,47 +59,47 @@ class WebservicesUserTest extends CommonClassTest
|
||||
public function testWSUserGetUser()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_user.php';
|
||||
$WS_METHOD = 'getUser';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
$ns = 'http://www.dolibarr.org/ns/';
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__." Create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient) {
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->soap_defencoding = 'UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
//$soapclient->setDebugLevel(5);
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>''
|
||||
$authentication = array(
|
||||
'dolibarrkey' => getDolGlobalString('WEBSERVICES_KEY'),
|
||||
'sourceapplication' => 'DEMO',
|
||||
'login' => 'admin',
|
||||
'password' => 'admin',
|
||||
'entity' => ''
|
||||
);
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication,'id'=>0,'ref'=>'admin');
|
||||
$result = '';
|
||||
$parameters = array('authentication' => $authentication,'id' => 0,'ref' => 'admin');
|
||||
print __METHOD__." Call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
|
||||
} catch (SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
$result = 0;
|
||||
}
|
||||
if (!empty($result['faultstring'])) {
|
||||
print $result['faultstring']."\n";
|
||||
$result=0;
|
||||
$result = 0;
|
||||
}
|
||||
if (! $result) {
|
||||
//var_dump($soapclient);
|
||||
@@ -115,14 +115,14 @@ class WebservicesUserTest extends CommonClassTest
|
||||
$this->assertEquals('OK', empty($result['result']['result_code']) ? '' : $result['result']['result_code'], 'Test on ref admin');
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication,'id'=>0,'ref'=>'refthatdoesnotexists');
|
||||
$result = '';
|
||||
$parameters = array('authentication' => $authentication,'id' => 0,'ref' => 'refthatdoesnotexists');
|
||||
print __METHOD__."Call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
|
||||
} catch (SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
$result = 0;
|
||||
}
|
||||
if (! $result || !empty($result['faultstring'])) {
|
||||
//var_dump($soapclient);
|
||||
|
||||
@@ -69,7 +69,7 @@ if (empty($user->id)) {
|
||||
$user->rights->website = new stdClass();
|
||||
}
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,7 +36,7 @@ if (empty($user->id)) {
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,17 +56,17 @@ class XCalLibTest extends CommonClassTest
|
||||
public function testQuotedPrintEncodeDecode()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$stringtoencode='ABCD=1234;';
|
||||
$result=quotedPrintEncode($stringtoencode);
|
||||
$stringtoencode = 'ABCD=1234;';
|
||||
$result = quotedPrintEncode($stringtoencode);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('ABCD=3D1234;', $result);
|
||||
|
||||
$resultback=quotedPrintDecode($result);
|
||||
$resultback = quotedPrintDecode($result);
|
||||
print __METHOD__." result=".$resultback."\n";
|
||||
$this->assertEquals($stringtoencode, $resultback);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ class TakePosFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
|
||||
{
|
||||
$this->url('/admin/const.php');
|
||||
$this->authenticate();
|
||||
$main_features_level_path='//input[@value="MAIN_FEATURES_LEVEL"]/following::input[@type="text"]';
|
||||
$main_features_level_path = '//input[@value="MAIN_FEATURES_LEVEL"]/following::input[@type="text"]';
|
||||
$main_features_level = $this->byXPath($main_features_level_path);
|
||||
$main_features_level->clear();
|
||||
$main_features_level->value('2');
|
||||
@@ -179,7 +179,7 @@ class TakePosFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
|
||||
{
|
||||
$this->url('/admin/modules.php');
|
||||
$this->authenticate();
|
||||
$module_status_image_path='//a[contains(@href, "' . self::$module_id . '")]/img';
|
||||
$module_status_image_path = '//a[contains(@href, "' . self::$module_id . '")]/img';
|
||||
$module_status_image = $this->byXPath($module_status_image_path);
|
||||
if (strstr($module_status_image->attribute('src'), 'switch_off.png')) {
|
||||
// Enable the module
|
||||
|
||||
Reference in New Issue
Block a user